Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting different parsed user agent on same machine #102

Open
SeanWhipple opened this issue Apr 1, 2020 · 1 comment
Open

Getting different parsed user agent on same machine #102

SeanWhipple opened this issue Apr 1, 2020 · 1 comment

Comments

@SeanWhipple
Copy link

SeanWhipple commented Apr 1, 2020

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

requirements_files.zip

@gil9red
Copy link

gil9red commented Feb 9, 2021

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@SeanWhipple @gil9red and others