sfactor
sfactor

Reputation: 13062

Is there any way to detect if a user agent is from a browser or an app?

I need to differentiate whether a User-Agent string from an HTTP header is from a mobile (iOS & Android) browser or a app. Is there any tool/library, preferably in Python which can help me with that?

Upvotes: 3

Views: 6467

Answers (1)

bagrat
bagrat

Reputation: 7418

user-agents is a fairly simple package for Python, which parses the User-Agent string.

from user_agents import parse

user_agent = parse(user_agent_string)
user_agent.os.family  # This will get you what you need

So having the OS family you can judge whether the request is made from a desktop browser or mobile browser or app client.

Upvotes: 7

Related Questions