Code Monkey home page Code Monkey logo

httpagentparser's People

Contributors

andrin-n-dream avatar buglloc avatar dimaryaz avatar dlebech avatar doismellburning avatar fabaff avatar gilgitik avatar id0sch avatar joemeister avatar karlcow avatar lostbenjamin avatar mariusvniekerk avatar mattrobenolt avatar mousetail avatar nigelmcnie avatar ojarva avatar patrickdessalle avatar pepijndevos avatar pykler avatar quique0194 avatar robertaistleitner avatar schwers avatar shon avatar srs81 avatar sumanlongtail avatar thepug avatar todoa2c avatar vpolikarpov avatar yin8086 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

httpagentparser's Issues

Devices have dist version and os version

I am having the issue where and Ipad or Nokia Lumia is detected they return a version for dist and os. I only want a version for one or the other. How could this be fixed??

What I have:

"Mozilla/5.0 (iPad;U;CPU OS 5_1_1 like Mac OS X; zh-cn)AppleWebKit/534.46.0(KHTML, like Gecko)CriOS/19.0.1084.60 Mobile/9B206 Safari/7534.48.3"

What parser tells me:

{'bot': False,
'browser': {'name': 'ChromeiOS', 'version': '19.0.1084.60'},
'dist': {'name': 'IPad', 'version': '5.1.1'},
'os': {'name': 'iOS', 'version': 'U;CPU'},
'platform': {'name': 'iOS', 'version': '5.1.1'}}

Chrome in Nexus 5 is detected as Opera

the following user agent is detected as opera

Mozilla/5.0 (Linux; Android 8.0.0; Nexus 5X Build/OPR6.170623.023) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.84 Mobile Safari/537.36

the problem is: OPR6.170623.023

I would appreciate your assistance since its affecting production,
thanks.

Android version is invalid when user agent contains no device name after OS version

User agent:

Mozilla/5.0 (Linux; Android 8.1.0) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/76.0.3809.111 Mobile Safari/537.36

Parsed:

{
  'platform': {
    'name': 'Android', 
    'version': '8.1.0) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/76.0.3809.111 Mobile Safari/537.36'
  }, 
  'os': {
    'name': 'Linux'
  }, 
  'bot': False, 
  'dist': {
    'name': 'Android', 
    'version': '8.1.0) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/76.0.3809.111 Mobile Safari/537.36'
  }, 
  'browser': {
    'name': 'Chrome', 
    'version': '76.0.3809.111'
  }
}

"CFNetworks" issue

I get an error trying to parse such user agent "CFNetwork/548.0.4 Darwin/11.0.0" it is user agent for Apple iPhone SDK requests.

pip install return error

pip install/easy_install called in a virtualenv -p python3

I checked
http://guide.python-distribute.org/creation.html your setup is OK
I checked your MANIFEST.in OK
I checked the presence of README.rst it is OK
I checked the doc, you play by the rules.

I am clueless. Removing l7 in setup.py and doing
python /home/jul/src/parse3/build/httpagentparser/setup.py install works however.

Downloading/unpacking httpagentparser
Real name of requirement httpagentparser is httpagentparser
Downloading httpagentparser-1.1.0.tar.gz
Running setup.py egg_info for package httpagentparser
Traceback (most recent call last):
File "", line 14, in
File "/home/jul/src/parse3/build/httpagentparser/setup.py", line 7, in
long_description=file("README.rst").read(),
NameError: name 'file' is not defined
Complete output from command python setup.py egg_info:
Traceback (most recent call last):

File "", line 14, in

File "/home/jul/src/parse3/build/httpagentparser/setup.py", line 7, in

long_description=file("README.rst").read(),

NameError: name 'file' is not defined

MSIE detection incorrect when multiple "MSIE X.Y;" sections present in UA

For example, this UA spotted in the wild:

Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; SLCC1; .NET CLR 2.0.50727; InfoPath.1; .NET CLR 3.5.30729; .NET CLR 3.0.30618; .NET4.0C)

Detects as:

{'os': {'version': 'XP', 'name': 'Windows'}, 'browser': {'version': '6.0', 'name': 'Microsoft Internet Explorer'}}

When it's actually IE8.

I traced the problem to the default getVersion implementation, which favours the last occurrence of MSIE in the version string.

I write a new one on the MSIE class, which favours the first one instead:

class MSIE(Browser):
    look_for = "MSIE" 
    skip_if_found = ["Opera"]
    name = "Microsoft Internet Explorer"
    version_splitters = [" ", ";"]
    def getVersion(self, agent):
        parts = agent.split(self.look_for + self.version_splitters[0])
        return parts[min(len(parts) - 1, 1)].split(self.version_splitters[1])[0].strip()

My one grabs the FIRST version detected rather than the last one.

I haven't provided this as a pull request, because the tests for MSIE are non-existent currently, so I have no idea if my change breaks a bunch of UAs in the wild.

I added a test case for this UA at least:

    ('Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; SLCC1; .NET CLR 2.0.50727; InfoPath.1; .NET CLR 3.5.30729; .NET CLR 3.0.30618; .NET4.0C)',
    ('Windows XP', 'Microsoft Internet Explorer 8.0'),
    {'os': {'version': 'XP', 'name': 'Windows'}, 'browser': {'version': '8.0', 'name': 'Microsoft Internet Explorer'}},),

I'd suggest adding a bunch of MSIE test cases first.

Old opera UserAgent not recognized correctly

I experienced a problem when parsing the browser version of a visitor on my website, and it boils down to that :

>>> import httpagentparser
>>> result = httpagentparser.detect("Opera/9.64(Windows NT 5.1; U; en) Presto/2.1.1")
>>> print result
{'platform': {'version': 'XP', 'name': 'Windows'}, 'os': {'version': 'XP', 'name': 'Windows'}, 'browser': {'version': '9.64(Windows', 'name': 'Opera'}}

I think it's because there should be a space between 4 and ( but still, this is an existing Opera user agent (http://www.useragentstring.com/Opera9.64_id_13933.php).

Thank you

Support Internet Explorer Compatibility mode versions?

Is there interest in updating support IE Compatibilty modes? Currently all compatibilty mode user agent strings return as showing Internet Explorer 7.0

Sample user agent:
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET4.0C; .NET4.0E; InfoPath.3; MS-RTC LM 8)

Current detection:
{'os': {'version': '7', 'name': 'Windows'}, 'browser': {'version': '7.0', 'name': 'Microsoft Internet Explorer'}}

Proposed detection:
{'os': {'version': '7', 'name': 'Windows'}, 'browser': {'version': '8.0 Compatibility View', 'name': 'Microsoft Internet Explorer'}}

Weird version number

Hey,

Pip lists httpagentparser as having version number '-1.7.2-' (including the dashes). This means you have to do the slightly weird 'pip install httpagentparser==-1.7.2-'

user-agent string raises exception

the following user-agent string causes an error:

>>> httpagentparser.detect(u'Sogou Mobile Spider1.0 for iPhone Android and Mozilla/5.0')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "httpagentparser/__init__.py", line 292, in detect
    if detector.detect(agent, result):
  File "httpagentparser/__init__.py", line 68, in detect
    version = self.getVersion(agent)
  File "httpagentparser/__init__.py", line 254, in getVersion
    return version.replace('_', '.')
UnboundLocalError: local variable 'version' referenced before assignment

Misdetection of a Firefox UA

What I have :

    "Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20100101 Firefox/10.0 (Chrome)"

What httpagentparser tells me :

    {'bot': False,
     'browser': {'name': 'Chrome', 'version': 'Mozilla/5.0'},
     'os': {'name': 'Linux'},
     'platform': {'name': 'Linux', 'version': None}}

Note that except the browser being Chrome, the version is wrong too.

What internet tells me :
Mainly Firefox but I'm not sur it corresponds to a real vendor UA, but it seems we can find clients using this UA...

no "os" detected for iPad

Found this iPad UA string in my server logs, but httpagentparser.detect() doesn't give an "os" field:

>>> httpagentparser.detect('Mozilla/5.0 (iPad; U; CPU OS 4_3_5 like Mac OS X; de-de) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8L1 Safari/6533.18.5')
{'flavor': {'version': 'X', 'name': 'MacOS'}, 'browser': {'version': '5.0.2', 'name': 'Safari'}}

Should this be fixed in the parser, or should I fall back to using "flavor" as OS?

Failing user agents (Opera 7, 8 and Netscape 8)

These user agents parse fine:
Opera/9.20 (Windows NT 6.0; U; en), Opera 9, Windows Vista
Opera/9.00 (Windows NT 5.1; U; en), Opera 9, Windows XP

These fail to parse the version correctly, returning something like "Opera Mozilla/4.0" for browser:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; en) Opera 8.50
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; en) Opera 8.0
Mozilla/4.0 (compatible; MSIE 6.0; MSIE 5.5; Windows NT 5.1) Opera 7.02 [en]

This one fails to detect the browser altogether:
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20060127 Netscape/8.1

User Agent from Facebook's iPad App is not recognized properly

The User agent is:
Mozilla/5.0 (iPad; CPU OS 6_0_1 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Mobile/10A523 [FBAN/FBIOS;FBAV/5.3;FBBV/89182;FBDV/iPad3,1;FBMD/iPad;FBSN/iPhone OS;FBSV/6.0.1;FBSS/2; FBCR/;FBID/tablet;FBLC/en_US]

It is recognized as:
{'flavor': {'version': 'X) AppleWebKit/536.26 (KHTML, like Gecko) Mobile/10A523 [FBAN/FBIOS', 'name': 'MacOS'}, 'dist': {'version': 'X) AppleWebKit/536.26 (KHTML, like Gecko) Mobile/10A523 [FBAN/FBIOS', 'name': 'IPhone'}}

While the proper parsing from Safari in the same device reads:
{'flavor': {'version': 'X', 'name': 'MacOS'}, 'dist': {'version': 'X', 'name': 'IPad'}, 'browser': {'version': '6.0', 'name': 'Safari'}}

As you can see the dist name is wrongly parsed as "IPhone"

Version failing for OSX 10.6.6

running in AppEngine (Python 2.7?), hitting the site with OSX 10.6.6 in both Firefox and Chrome an attempt to decode the OS version number throws the error below (from AppEngine log)

using HTTPAgentParser 0.83

Let me know if theres anything else I can grab to help narrow this down...

500 5ms 0cpu_ms 0kb Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_6) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.3 Safari/534.24,gzip(gfe)
220.255.4.30 - - [15/Mar/2011:00:07:52 -0700] "GET /logger.js?i=83&sn=http%3A//blog.offbeatmammal.com/samples/jserr/jserr.html&fl=undefined&ln=undefined&err=%5Bobject%20Event%5D&ui=4E69BF15-0519-4B7B-9C0B-4A1CDD1563DE HTTP/1.1" 500 405 "http://blog.offbeatmammal.com/samples/jserr/jserr.html" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_6) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.3 Safari/534.24,gzip(gfe)" "jserrlog.appspot.com" ms=6 cpu_ms=0 api_cpu_ms=0 cpm_usd=0.000124
E 2011-03-15 00:07:52.898
'version'
Traceback (most recent call last):
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/init.py", line 515, in call
handler.get(*groups)
File "/base/data/home/apps/jserrlog/1.348961542918219578/logger.py", line 31, in get
QOSVer = httpagentparser.detect(QUA)['os']['version']
KeyError: 'version'

Support MS Edge as a browser

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240

We might want to check for Edge before checking for Chrome as with the above agent, we think that the browser is Chrome.

Include License in Source Code

Please include a reference to the license for the project (PyPi says its MIT) in the source somewhere.

This will keep corporate overlords happy, Thanks.

Blackberry not recognized

It would be neat if httpagentparser would detect BlackBerry browsers.

In some server logs I found the following UA strings containing BlackBerry:

"BlackBerry8310/4.5.0.174 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/124"
"BlackBerry8310/4.5.0.69 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/114"
"BlackBerry8520/4.6.1.314 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/124"
"BlackBerry8900/4.6.1.310 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/114"
"BlackBerry8900/5.0.0.1036 Profile/MIDP-2.1 Configuration/CLDC-1.1 VendorID/124"
"BlackBerry8900/5.0.0.681 Profile/MIDP-2.1 Configuration/CLDC-1.1 VendorID/124"
"BlackBerry9000/4.6.0.303 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/114"
"BlackBerry9000/5.0.0.1036 Profile/MIDP-2.1 Configuration/CLDC-1.1 VendorID/124"
"BlackBerry9300/5.0.0.794 Profile/MIDP-2.1 Configuration/CLDC-1.1 VendorID/114"
"BlackBerry9500/4.7.0.78 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/124"
"BlackBerry9500/5.0.0.841 Profile/MIDP-2.1 Configuration/CLDC-1.1 VendorID/124"
"BlackBerry9520/5.0.0.1077 Profile/MIDP-2.1 Configuration/CLDC-1.1 VendorID/124"
"BlackBerry9700/5.0.0.344 Profile/MIDP-2.1 Configuration/CLDC-1.1 VendorID/124"
"BlackBerry9700/5.0.0.442 Profile/MIDP-2.1 Configuration/CLDC-1.1 VendorID/612"
"BlackBerry9700/5.0.0.593 Profile/MIDP-2.1 Configuration/CLDC-1.1 VendorID/114"
"BlackBerry9700/5.0.0.593 Profile/MIDP-2.1 Configuration/CLDC-1.1 VendorID/114 Webwasher/6.8.7"
"BlackBerry9700/5.0.0.593 Profile/MIDP-2.1 Configuration/CLDC-1.1 VendorID/604"
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0) BlackBerry8700/4.1.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/100"
"Mozilla/5.0 (BlackBerry; U; BlackBerry 9700; de) AppleWebKit/534.8+ (KHTML, like Gecko) Version/6.0.0.448 Mobile Safari/534.8+"
"Mozilla/5.0 (BlackBerry; U; BlackBerry 9700; de) AppleWebKit/534.8+ (KHTML, like Gecko) Version/6.0.0.668 Mobile Safari/534.8+"
"Mozilla/5.0 (BlackBerry; U; BlackBerry 9700; es) AppleWebKit/534.8+ (KHTML, like Gecko) Version/6.0.0.344 Mobile Safari/534.8+"
"Mozilla/5.0 (BlackBerry; U; BlackBerry 9780; de) AppleWebKit/534.8+ (KHTML, like Gecko) Version/6.0.0.546 Mobile Safari/534.8+"
"Mozilla/5.0 (BlackBerry; U; BlackBerry 9800; de) AppleWebKit/534.1+ (KHTML, like Gecko) Version/6.0.0.246 Mobile Safari/534.1+"
"Mozilla/5.0 (BlackBerry; U; BlackBerry 9800; de) AppleWebKit/534.1+ (KHTML, like Gecko) Version/6.0.0.337 Mobile Safari/534.1+"

support for Opera version

looks like for the Opera useragent Opera/9.80 (Windows NT 6.1; U; Edition Next; en) Presto/2.10.229 Version/12.00 we're getting Opera v9.80 reported, not Version 12... not sure if it's an Opera or httpagentparser issue...

Tag the source

It would be very helpful if you could tag releases as well. This would enable distributions who want to run your tests to fetch the package from GitHub instead of Pypi, where the tests are excluded.

Thanks

Support mobile OS

Hello!
Do you plan add support mobile OS's - like iOS, Android....?

Maxthon 4 not recognised

Found this curiosity in the logs:

Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0; MSIE; Maxthon/4.1.3.5000)

Output:

{'browser': {'name': 'Microsoft Internet Explorer'},
 'os': {'name': 'Windows', 'version': '7'},
 'platform': {'name': 'Windows', 'version': '7'}}

I don't know much about Maxthon, but the UA says Trident/7.0 rv:11.0, so it looks like something IE11-powered.

(On related note, I also didn't expect detect() to return something that has ['browser'] but doesn't have ['browser']['version'].)

special iPhone-Agent without browser information?

Hey,

I'm using httpagentparser in my productive code on logged user agents, in order to create some platform- and browser-analysis.

One of the users was logged using
Mozilla/5.0 (iPhone; CPU iPhone OS 16_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 LightSpeed [FBAN/MessengerLiteForiOS;FBAV/403.1.0.38.106;FBBV/462753247;FBDV/iPhone15,3;FBMD/iPhone;FBSN/iOS;FBSV/16.4;FBSS/3;FBCR/;FBID/phone;FBLC/en;FBOP/0]

which yields no browser key in the resulting dictionary from httpagentparser.detect(line). What's your recommendation to handle this?

{'platform': {'name': 'iOS', 'version': '16.4'}, 'os': {'name': 'iOS'}, 'bot': False, 'dist': {'name': 'iPhone', 'version': '16.4'}}

Improper parsing for Windows NT

Hei Shon,

First of all, thanks for sharing this! I was looking for an agent parser, and found out your lib in python.org.

I don't know if you are aware of this or not, but I was running some tests and found some inconsistent parsing on the following user-agent:

import httpagentparser
s = "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.60 Safari/534.24"
print httpagentparser.detect(s)
{'os': {'version': 'NT 5.1) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.60 Safari/534.24', 'name': 'Windows'}, 'browser': {'version': '11.0.696.60', 'name': 'Chrome'}}

My computer is running Windows XP SP3, using Chrome 11.0.696.60. All other tests (Linux and Mac) went ok, just so you know.

I took the liberty to write a patch for this, so I pulling it to your code later on.

Thanks,

odd iPhone version detection

Mozilla/5.0 (iPhone; CPU iPhone OS 6_0_1 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Mobile/10A523 [FBAN/FBIOS;FBAV/5.1;FBBV/68414;FBDV/iPho

{'dist': {'name': 'IPhone',
'version': 'X) AppleWebKit/536.26 (KHTML, like Gecko) Mobile/10A523 [FBAN/FBIOS'},
'flavor': {'name': 'MacOS',
'version': 'X) AppleWebKit/536.26 (KHTML, like Gecko) Mobile/10A523 [FBAN/FBIOS'}}

Icecat support

Howdy,

first, thanks for the parser!
I found out that Icecat is not supported. The agent string can be e.g. "Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20111106 IceCat/7.0.1".

Best regards
Alex

MSOffice user agent not detected

Hi,

When I try it with the user agent
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729; Microsoft Outlook 16.0.5257; ms-office; MSOffice 16)

Instead of the correct output MS Office 16 (user agent when Outlook load a external image) , I get the result: Microsoft Internet Explorer 7.0

Do you know why ?

Support for Kindle Fire (Silk) UA strings

Is it possible to add support for the Kindle Fire devices
Fire: Mozilla/5.0 (Linux; U; en-us; KFOT Build/IML74K) AppleWebKit/535.19 (KHTML, like Gecko) Silk/2.2 Safari/535.19 Silk-Accelerated=true
Fire HD: Mozilla/5.0 (Linux; U; en-us; KFTT Build/IML74K) AppleWebKit/535.19 (KHTML, like Gecko) Silk/2.0 Safari/535.19 Silk-Accelerated=true
Fire HD 8.9 WiFi: Mozilla/5.0 (Linux; U; en-us; KFJWI Build/IML74K) AppleWebKit/535.19 (KHTML, like Gecko) Silk/2.2 Safari/535.19 Silk-Accelerated=true
Fire HD 8.9 WAN: Mozilla/5.0 (Linux; U; en-us; KFJWA Build/IML74K) AppleWebKit/535.19 (KHTML, like Gecko) Silk/2.2 Safari/535.19 Silk-Accelerated=true

the Silk version number seems to vary between 2.0 and 2.2 at the moment, and the Build has varied, but "Silk-Accelerated" seems to be a common factor (true means it goes via EC2, false means it's going direct with no acceleration)

IE 11 / Windows 8.1 support

Does httpagentparser yet support IE11 and Windows 8.1?

Here's a user-agent string I grabbed from my install of 8.1:

Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko

py3 compliance?

init.py L313 s/print "detector name: ", detector.name/print("detector name: ", detector.name)/
and then, yop you are py3 compliant at my experience. (I have not rerun your unittest though)

iPad user agent not being recognized

With this user agent "AppleCoreMedia/1.0.0.10B329 (iPad; U; CPU OS 6_1_3 like Mac OS X; en_us)" this variable look_for = 'iPad; CPU OS' in the line 436 is not being triggered.

While other iPads missing the U; like this "Mozilla/5.0 (iPad; CPU OS 7_1 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Version/7.0 Mobile/11D167 Safari/9537.53" are being detected correctly.

several bots not recognized

I manually looked through some logs and feed it into httpagendparser and found several wrongly identified user agents, including high profiles google bot:

>>> httpagentparser.detect("Mozilla/5.0 (compatible; AhrefsBot/6.1; +http://ahrefs.com/robot/)")
{'platform': {'name': None, 'version': None}}

>>> httpagentparser.detect("Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.96 Mobile Safari/537.36 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)")
{'platform': {'name': 'Android', 'version': '6.0.1'}, 'os': {'name': 'Linux'}, 'bot': False, 'dist': {'name': 'Android', 'version': '6.0.1'}, 'browser': {'name': 'Chrome', 'version': '41.0.2272.96'}}

>>> httpagentparser.detect("Mozilla/5.0 (X11; U; Linux Core i7-4980HQ; de; rv:32.0; compatible; JobboerseBot; http://www.jobboerse.com/bot.htm) Gecko/20100101 Firefox/38.0")
{'platform': {'name': 'Linux', 'version': None}, 'os': {'name': 'Linux'}, 'bot': False, 'browser': {'name': 'Firefox', 'version': '38.0'}}

>>> httpagentparser.detect("crawler_eb_germany")
{'platform': {'name': None, 'version': None}}

>>> httpagentparser.detect("Mozilla/5.0 (compatible; Qwantify/Bleriot/1.1; +https://help.qwant.com/bot)")
{'platform': {'name': None, 'version': None}}

>>> httpagentparser.detect("Mozilla/5.0 (compatible; SemrushBot/6~bl; +http://www.semrush.com/bot.html)")
{'platform': {'name': None, 'version': None}}

>>> httpagentparser.detect("Mozilla/5.0 (compatible; AhrefsBot/6.1; +http://ahrefs.com/robot/)")
{'platform': {'name': None, 'version': None}}

>>> httpagentparser.detect("ZoominfoBot (zoominfobot at zoominfo dot com)")
{'platform': {'name': None, 'version': None}}

Support for ChromeOS

Looks like it's not a fan of ChromeOS at the moment

Mozilla/5.0 (X11; CrOS i686 0.0.0) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.27 Safari/534.24,gzip(gfe)

I'm going to have to learn how to submit these changes myself aren't I :)

Doesnt' detect chrome version correctly...

"Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.97 Safari/537.22"

detect gives following:

{'os': {'version': '7', 'name': 'Windows'}, 'browser': {'version': 'Mozilla/5.0', 'name': 'Chrome'}}

but the Chrome version is '25.0.1364.97' ...

Rises exception for 'CrOS' useragent

I've encountered an exception 'IndexError: list index out of range' for strange looking useragent but which came from real access logs:

httpagentparser.detect('U2FsdGVkX1+5L0CpGMQohbnvtzmODt2R90PGcmXwMt57gT+ESJFNzBwF7fpA/Gcw9UiEcsdP0U0G59A/FZT0FJZwvXy1UxNSYx/rct9YmQK1cYYFxRhIZjxFVT0SN1oncZ3TJfcbDl2EaSS7y5dXr/4lNC6Nue/5eY2YxB/PagNdHBZrQljNijjZ1q0xKn+02cUAvfLowYnPzmdXXMQbGI9z2vlxf+T5OScrQnfZeqOtfotYBKTueiCrOSkbLmH0bF25eO1y5cAQqOWb9PUw9Q==')

The same exception rises for 'CrOS' useragent:

print httpagentparser.detect('CrOS')

Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/dist-packages/httpagentparser/init.py", line 343, in detect
if detector.detect(agent, result):
File "/usr/local/lib/python2.7/dist-packages/httpagentparser/init.py", line 70, in detect
version = self.getVersion(agent)
File "/usr/local/lib/python2.7/dist-packages/httpagentparser/init.py", line 293, in getVersion
return agent.split(self.look_for + version_markers[0])[-1].split(version_markers[1])[1].strip()[:-1]
IndexError: list index out of range

getting `platform` name value as None

I tried to authenticate my website through Facebook using social auth, but in some case I am getting platform as None, which is breaking the functionality of my website.
Browser Used: Chrome

Note: I am unable to provide the Agent string because we were unable to log that.

Kindly help me on that.

Jakarta Commons-HttpClient/3.1 not recognized

First of all, thanks for your great parser.

I'm using it to parse http clients logs from rackspace and reported issue happens with the client information of Jakarta Commons-HttpClient/3.1.

Any ideas how to solve that?

Some strings that cannot be parsed

Currently I am using this decent library to parse user-agents strings.
However, I found some strings that cannot be parsed. I would paste them here,
in case they are useful.

Mozilla/5.0+(X11;+CrOS+i686+2465.163.0)+AppleWebKit/537.1+(KHTML,+like+Gecko)+Chrome/21.0.1180.91+Safari/537.1

Mozilla/5.0+(X11;+CrOS+i686+2268.111.0)+AppleWebKit/536.11+(KHTML,+like+Gecko)+Chrome/20.0.1132.57+Safari/536.11

Netscape broke Chrome recognition

For strings like :
Netscape(5.0 (Windows NT 6.1) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.186 Safari/535.1)
Netscape(5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/534.10 (KHTML, like Gecko) Chrome/8.0.552.237 Safari/534.10)
Netscape(5.0 (Windows NT 6.1) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.186 Safari/535.1)
Netscape(5.0 (Windows NT 6.1) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.112 Safari/535.1)
Netscape(5.0 (Windows NT 6.1) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.112 Safari/535.1)
Netscape(5.0 (Windows NT 6.1) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.112 Safari/535.1)

Simple_parse returning : Netscape ...
Fix Netscape recognition like this :

class Netscape(Browser):
look_for = "Netscape"
#--- if find 'Chrome' - browser type = 'Chrome' ---
def checkWords(self, agent):
unless_list = ["Chrome"]
if self.look_for in agent:
for word in unless_list:
if word in agent:
return False
return True

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.