selwin / python-user-agents

A Python library that provides an easy way to identify devices like mobile phones, tablets and their capabilities by parsing (browser) user agent strings.
MIT License
1.45k stars 199 forks source link

Firefox for Android issues #7

Open miketaylr opened 10 years ago

miketaylr commented 10 years ago

Hi there,

A few issues with Firefox for Android user agents:

>>> ua_string = 'Mozilla/5.0 (Android; Mobile; rv:26.0) Gecko/26.0 Firefox/26.0'
>>> b = parse(ua_string)
>>> b.browser
Browser(family=u'Firefox Mobile', version=(26,), version_string='26')
>>> b.is_touch_capable
True
>>> b.is_tablet
True
>>> b.os
OperatingSystem(family='Android', version=(), version_string='')
>>> b.is_mobile
False
>>> 

is_tablet should be false, is_mobile should be true.

selwin commented 10 years ago

Thanks for the report.

Does Firefox also have a version for tablet devices? I just want to make sure that we can properly differentiate between tablet and mobile Firefoxes.

selwin commented 10 years ago

Never mind my question. I saw this issue before #6

karlcow commented 8 years ago

I guess we can close this as fixed!

>>> from user_agents import parse
>>> ua = 'Mozilla/5.0 (Android 4.4.4; Mobile; rv:44.0) Gecko/44.0 Firefox/44.0'
>>> user_agent = parse(ua)
>>> # Accessing user agent's browser attributes
... user_agent.browser  
Browser(family='Firefox Mobile', version=(44,), version_string='44')
>>> user_agent.browser.family  
'Firefox Mobile'
>>> user_agent.browser.version 
(44,)
>>> user_agent.browser.version_string
'44'
>>> 
>>> # Accessing user agent's operating system properties
... user_agent.os  
OperatingSystem(family='Android', version=(4, 4, 4), version_string='4.4.4')
>>> user_agent.os.family  
'Android'
>>> user_agent.os.version 
(4, 4, 4)
>>> user_agent.os.version_string
'4.4.4'
>>> 
>>> # Accessing user agent's device properties
... user_agent.device  
Device(family='Generic Smartphone', brand='Generic', model='Smartphone')
>>> user_agent.device.family 
'Generic Smartphone'
>>> user_agent.device.brand 
'Generic'
>>> user_agent.device.model
'Smartphone'
>>> 
>>> # Viewing a pretty string version
... str(user_agent) 
'Generic Smartphone / Android 4.4.4 / Firefox Mobile 44'
>>> # Viewing a pretty string version
... str(user_agent) 
'Generic Smartphone / Android 4.4.4 / Firefox Mobile 44'
>>> user_agent.is_touch_capable
True
>>> user_agent.is_tablet
False
>>> user_agent.is_mobile
True