This example shows how to retrieve property meta data from the 51Degrees
cloud service.
This feature can be used to get information such as the category that
a property belongs to or the possible values a property can have.
(At the time of the request. If the data file being used by the cloud
service is updated, the possible values for a property can change)
1 [List of properties
with names
and categories]
3 Does user agent Mozilla/5.0 (iPhone; CPU iPhone OS 11_2 like Mac OS X) AppleWebKit/604.4.7 (KHTML, like Gecko) Mobile/15C114 support svg? :
5 Does user agent Mozilla/5.0 (iPhone; CPU iPhone OS 11_2 like Mac OS X) AppleWebKit/604.4.7 (KHTML, like Gecko) Mobile/15C114 support video? :
7 Does user agent Mozilla/5.0 (iPhone; CPU iPhone OS 11_2 like Mac OS X) AppleWebKit/604.4.7 (KHTML, like Gecko) Mobile/15C114 support supportstls/ssl? :
9 Does user agent Mozilla/5.0 (iPhone; CPU iPhone OS 11_2 like Mac OS X) AppleWebKit/604.4.7 (KHTML, like Gecko) Mobile/15C114 support supportswebgl? :
45 from fiftyone_devicedetection.devicedetection_pipelinebuilder
import DeviceDetectionPipelineBuilder
52 resourceKey =
"!!YOUR_RESOURCE_KEY!!" 54 if resourceKey ==
"!!YOUR_RESOURCE_KEY!!":
56 You need to create a resource key at 57 https://configure.51degrees.com and paste it into the code, 58 'replacing !!YOUR_RESOURCE_KEY!! 59 To include the properties used by this example go to https://configure.51degrees.com/CfLML6rg 63 pipeline = DeviceDetectionPipelineBuilder({
"resourceKey": resourceKey}).build()
67 properties = pipeline.get_properties()
71 for propertyKey, propertyMeta
in properties[
"device"].items():
72 print(propertyKey +
" of category " + propertyMeta[
"category"])
78 flowData = pipeline.create_flowdata()
81 iphoneUA =
"Mozilla/5.0 (iPhone; CPU iPhone OS 11_2 like Mac OS X) AppleWebKit/604.4.7 (KHTML, like Gecko) Mobile/15C114" 83 flowData.evidence.add(
"header.user-agent", iphoneUA)
91 mediaSupport = flowData.get_where(
"category",
"Supported Media")
93 for supportedMediaProperty, supportedValue
in mediaSupport.items():
94 print(
"Does User-Agent " + iphoneUA +
" support " + supportedMediaProperty +
"?")
95 if supportedValue.has_value():
96 print(supportedValue.value())
98 print(supportedValue.no_value_message())