Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bafc4db

Browse filesBrowse files
committed
Updated README.rst.
1 parent 5d378c6 commit bafc4db
Copy full SHA for bafc4db

File tree

Expand file treeCollapse file tree

1 file changed

+8
-7
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-7
lines changed

‎README.rst

Copy file name to clipboardExpand all lines: README.rst
+8-7Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@ and `os` attributes. For example:
3131

3232
.. code-block:: python
3333
34-
import user_agents
34+
from user_agents import parse
3535
3636
# iPhone's user agent string
3737
ua_string = 'Mozilla/5.0 (iPhone; CPU iPhone OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B179 Safari/7534.48.3'
38+
user_agent = parse(ua_string)
3839
3940
# Accessing user agent's browser attributes
4041
user_agent.browser # returns Browser(family=u'Mobile Safari', version=(5, 1), version_string='5.1')
@@ -69,43 +70,43 @@ For example:
6970

7071
.. code-block:: python
7172
72-
import user_agents
73+
from user_agents import parse
7374
7475
# Let's start from an old, non touch Blackberry device
7576
ua_string = 'BlackBerry9700/5.0.0.862 Profile/MIDP-2.1 Configuration/CLDC-1.1 VendorID/331 UNTRUSTED/1.0 3gpp-gba'
76-
user_agent = user_agents.parse(ua_string)
77+
user_agent = parse(ua_string)
7778
user_agent.is_mobile # returns True
7879
user_agent.is_tablet # returns False
7980
user_agent.is_touch_capable # returns False
8081
user_agent.is_pc # returns False
8182
8283
# Now a Samsung Galaxy S3
8384
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'
84-
user_agent = user_agents.parse(ua_string)
85+
user_agent = parse(ua_string)
8586
user_agent.is_mobile # returns True
8687
user_agent.is_tablet # returns False
8788
user_agent.is_touch_capable # returns True
8889
user_agent.is_pc # returns False
8990
9091
# iPad's user agent string
9192
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'
92-
user_agent = user_agents.parse(ua_string)
93+
user_agent = parse(ua_string)
9394
user_agent.is_mobile # returns False
9495
user_agent.is_tablet # returns True
9596
user_agent.is_touch_capable # returns True
9697
user_agent.is_pc # returns False
9798
9899
# Kindle Fire's user agent string
99100
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'
100-
user_agent = user_agents.parse(ua_string)
101+
user_agent = parse(ua_string)
101102
user_agent.is_mobile # returns False
102103
user_agent.is_tablet # returns True
103104
user_agent.is_touch_capable # returns True
104105
user_agent.is_pc # returns False
105106
106107
# Touch capable Windows 8 device
107108
ua_string = 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0; Touch)'
108-
user_agent = user_agents.parse(ua_string)
109+
user_agent = parse(ua_string)
109110
user_agent.is_mobile # returns False
110111
user_agent.is_tablet # returns False
111112
user_agent.is_touch_capable # returns True

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.