Skip to content Skip to sidebar Skip to footer

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

Solution 1:

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.


Post a Comment for "Is There Any Way To Detect If A User Agent Is From A Browser Or An App?"