ua-parser
ua-parser is an User-Agent header string parser for Python. It's inspired by javascript package with the same name ua-parser and performs identifcal functionality but in Python.
In web scraping, ua-parser is used in anti-scraping bypass. It helps to design user agent string rotation in scraper fingerprinting by providing consisten and reliably information about user agents.
Example Use
from ua_parser import user_agent_parser
user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:106.1) Gecko/20100020 Firefox/109.0"
parsed = user_agent_parser.Parse(user_agent)
print(parsed)
{
"device": {
"brand": "Apple",
"family": "Mac",
"model": "Mac",
},
"os": {
"family": "Mac OS X",
"major": "10",
"minor": "15",
"patch": None,
"patch_minor": None,
},
"string": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:106.1) Gecko/20100020 Firefox/109.0",
"user_agent": {
"family": "Firefox",
"major": "109",
"minor": "0",
"patch": None,
},
}