Closed brunobraga closed 13 years ago
Maybe a good idea would be to use a site like: http://www.useragentstring.com/pages/Browserlist/ to fully execute a unit-test on this (maybe in a separate test.py file).
Thanks brunobraga for reporting this and sure a patch is welcome. Bit busy atm, but will think about your other idea about test.py or may be you can contribute if possible.
Commited. https://github.com/brunobraga/httpagentparser/commit/13ee456d6976ad996822bfdc22f49cfc36033878
This issue is covered in line 195:
- return agent.split('Windows')[-1].split(';')[0].strip()
+ temp = agent.split('Windows')[-1]
+ if temp.find(";") > -1:
+ return temp.split(';')[0].strip()
+ else:
+ return temp.split(')')[0].strip()
Hei shon,
I was looking more carefully at the web-site from previous comment, and found they have an API... http://www.useragentstring.com/?getJSON=all
Although we can not rely on third-party for a lib, it may be a nice approach to avoid handling all weird cases out there.
Hi brunobraga,
New version with this fix is now available on pypi. Your suggestion about useragentstring.com is useful, thanks. Rightnow I am busy into some other things so will think about it later. Or better if somebody volunteers for it.
Cheers!
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:
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,