python-user-agents
python-user-agents copied to clipboard
Getting different parsed user agent on same machine
I have two python virtual environments that are installed on the same Mac. And when I try to parse a user agent one virtual environment is giving a different answer than the other. While the envs are not exactly the same I'm surprised to see these outputs.
One environment gives the following (attached requirements file r1)
In [1]: import user_agents
In [2]: user_agent_str = (
...: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 ("
...: "KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36"
...: )
In [3]: user_agents.parse(user_agent_str).device
Out[3]: Device(family='Other', brand=None, model=None)
The second environment gives (requirements file r2)
>>> import user_agents
>>> user_agent_str = (
... "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 ("
... "KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36"
... )
>>> user_agents.parse(user_agent_str).device
Device(family='Mac', brand='Apple', model='Mac')
>>>
The two requirements files are attached for debugging. Both python environments are running 3.7.4
It is not python-user-agents that parses the string, but uap-python. I think if you parse the string through it, you will see the difference in it for the two environments
from ua_parser import user_agent_parser
import pprint
user_agent_str = (
...
)
parsed_string = user_agent_parser.Parse(ua_string)
pp = pprint.PrettyPrinter(indent=4)
pp.pprint(parsed_string)