hamaxx / uasparser2

Fast and reliable User Agent parser for python
Other
31 stars 13 forks source link

User Agents detected as unknown #6

Closed kaittodesk closed 10 years ago

kaittodesk commented 10 years ago

I have trouble using versions 0.2 and newer to detect User Agents - they are detected as "unknown".

For example, if I have a User Agent string:

Outlook-Express/7.0 (MSIE 7.0; Windows NT 6.1; WOW64; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; HPNTDF; .NET4.0C; .NET4.0E; TmstmpExt)

Running a simple parse against that string:

from uasparser2 import UASParser
p = UASParser(cache_dir='/tmp', cache_ttl=3600*24*7, mem_cache_size=1000)
p.parse('Outlook-Express/7.0 (MSIE 7.0; Windows NT 6.1; WOW64; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; HPNTDF; .NET4.0C; .NET4.0E; TmstmpExt)')

will result in unknown User Agent in version 0.2 and newer:

{
  "ua_name": "unknown",
  "ua_company": "unknown",
  "os_name": "Windows 7",
  "ua_family": "unknown",
  "device_type": "Personal computer",
  "os_company": "Microsoft Corporation.",
  "ua_info_url": "unknown",
  "os_icon": "windows-7.png",
  "os_url": "http://en.wikipedia.org/wiki/Windows_7",
  "typ": "unknown",
  "ua_company_url": "unknown",
  "ua_icon": "unknown.png",
  "device_icon": "desktop.png",
  "ua_url": "unknown",
  "device_info_url": "/list-of-ua/device-detail?device=Personal computer",
  "os_family": "Windows",
  "os_company_url": "http://www.microsoft.com/"
}

Expected result would be, as it is with version 0.1.1:

{
  "ua_name": "Windows Live Mail",
  "typ": "Email client",
  "ua_company_url": "http://www.microsoft.com/",
  "os_icon": "windows-7.png",
  "ua_company": "Microsoft Corporation.",
  "os_name": "Windows 7",
  "ua_family": "Windows Live Mail",
  "ua_url": "http://download.live.com/wlmail",
  "os_company_url": "http://www.microsoft.com/",
  "os_company": "Microsoft Corporation.",
  "os_family": "Windows",
  "ua_info_url": "http://user-agent-string.info/list-of-ua/browser-detail?browser=Windows Live Mail",
  "ua_icon": "Windows_Live_Mail.png",
  "os_url": "http://en.wikipedia.org/wiki/Windows_7"
}

I'm using Python 2.7.3 on Debian 7.6, and have the following Python packages installed (uasparser2 not listed):

Jinja2==2.6
M2Crypto==0.21.1
Mako==0.7.0
MarkupSafe==0.15
MySQL-python==1.2.3
PyYAML==3.10
SOAPpy==0.12.0
SQLAlchemy==0.9.6
amqp==1.4.5
anyjson==0.3.3
argparse==1.2.1
astroid==1.1.1
billiard==3.3.0.18
celery==3.1.13
chardet==2.0.1
distribute==0.6.24dev-r0
fpconst==0.7.2
hiredis==0.1.4
invoke==0.8.2
kombu==3.0.21
logilab-common==0.62.0
msgpack-python==0.1.10
nose==1.3.3
pycrypto==2.6
pylint==1.2.1
python-apt==0.8.8.2
python-debian==0.1.21
python-debianbts==1.11
pytz==2014.4
pyzmq==13.1.0
redis==2.10.1
reportbug==6.4.4
salt==2014.1.7
wsgiref==0.1.2

I must be missing something really simple, right?

hamaxx commented 10 years ago

Confirmed. I'll try to fix it asap.

Thanks!

hamaxx commented 10 years ago

@kaittodesk Can you please try the updated master.

kaittodesk commented 10 years ago

Works as expected.

Thanks for your prompt response!

hamaxx commented 10 years ago

Pushed v0.3.1 to pypi.

Thanks for reporting this.