You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 26, 2023. It is now read-only.
Copy file name to clipboardExpand all lines: README.rst
+15-4Lines changed: 15 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
1
Python User Agents
2
2
==================
3
3
4
-
``user_agents`` is a Python library that provides an easy way to identify devices like mobile phones,
5
-
tablets and their capabilities by parsing (browser) user agent strings. The goal is to reliably
4
+
``user_agents`` is a Python library that provides an easy way to identify/detect devices like mobile
5
+
phones, tablets and their capabilities by parsing (browser) user agent strings. The goal is to reliably
6
6
detect whether:
7
7
8
8
* User agent is a mobile, tablet or PC based device
@@ -12,7 +12,7 @@ detect whether:
12
12
actual parsing of the raw user agent string.
13
13
14
14
This library should be considered "alpha". Please post feature suggestions, bug or pull requests to
15
-
identify more devices on Github.
15
+
identify more devices on `Github<https://github.com/selwin/python-user-agents>`_
16
16
17
17
18
18
Installation
@@ -26,7 +26,7 @@ WARNING: This library should be considered "alpha". Use this in production at yo
26
26
pip install pyyaml ua-parser user-agents
27
27
28
28
Alternatively, you can also get the latest source code from
29
-
`Github<https://github.com/selwin/python-user-agents>`_ and install it manually.
29
+
`Github`_ and install it manually.
30
30
31
31
Usage
32
32
=====
@@ -69,6 +69,7 @@ Currently these attributes are supported:
69
69
* ``is_tablet``: whether user agent is identified as a tablet device (iPad, Kindle Fire, Nexus 7 etc)
70
70
* ``is_pc``: whether user agent is identified to be running a traditional "desktop" OS (Windows, OS X, Linux)
71
71
* ``is_touch_capable``: whether user agent has touch capabilities
72
+
* ``is_bot``: whether user agent is a search engine crawler/spider
72
73
73
74
74
75
For example:
@@ -84,6 +85,7 @@ For example:
84
85
user_agent.is_tablet # returns False
85
86
user_agent.is_touch_capable # returns False
86
87
user_agent.is_pc # returns False
88
+
user_agent.is_bot # returns False
87
89
88
90
# Now a Samsung Galaxy S3
89
91
ua_string ='Mozilla/5.0 (Linux; U; Android 4.0.4; en-gb; GT-I9300 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30'
@@ -92,6 +94,7 @@ For example:
92
94
user_agent.is_tablet # returns False
93
95
user_agent.is_touch_capable # returns True
94
96
user_agent.is_pc # returns False
97
+
user_agent.is_bot # returns False
95
98
96
99
# iPad's user agent string
97
100
ua_string ='Mozilla/5.0(iPad; U; CPU iPhone OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B314 Safari/531.21.10'
@@ -100,6 +103,7 @@ For example:
100
103
user_agent.is_tablet # returns True
101
104
user_agent.is_touch_capable # returns True
102
105
user_agent.is_pc # returns False
106
+
user_agent.is_bot # returns False
103
107
104
108
# Kindle Fire's user agent string
105
109
ua_string ='Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us; Silk/1.1.0-80) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16 Silk-Accelerated=true'
@@ -108,6 +112,7 @@ For example:
108
112
user_agent.is_tablet # returns True
109
113
user_agent.is_touch_capable # returns True
110
114
user_agent.is_pc # returns False
115
+
user_agent.is_bot # returns False
111
116
112
117
# Touch capable Windows 8 device
113
118
ua_string ='Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0; Touch)'
@@ -116,6 +121,7 @@ For example:
116
121
user_agent.is_tablet # returns False
117
122
user_agent.is_touch_capable # returns True
118
123
user_agent.is_pc # returns True
124
+
user_agent.is_bot # returns False
119
125
120
126
121
127
Running Tests
@@ -127,6 +133,11 @@ Running Tests
127
133
Changelog
128
134
=========
129
135
136
+
Version 0.1.1
137
+
-------------
138
+
* Added ``is_bot`` property
139
+
* Symbian OS devices are now detected as a mobile device
0 commit comments