Simple user agent generator and interpreter tools
Project description
User Agent Tools
This project provides a Python class UA
for working with user agent strings. It offers functionality for generating random user agents, interpreting user agent strings, and extracting information about operating systems, browsers, and platforms.
Features
- Generate random user agents with optional browser and system filters
- Interpret user agent strings to extract OS, browser, and platform information
Usage
from user_agent_tools import UA
# Initialize the UA class
ua_tools = UA()
# Generate a random user agent
random_ua = ua_tools.random()
print(f"Random User Agent: {random_ua}")
# Generate a random user agent for Chrome on Windows
chrome_windows_ua = ua_tools.random(browser="Chrome", system="Windows")
print(f"Random Chrome on Windows User Agent: {chrome_windows_ua}")
# Interpret a user agent string
ua_string = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"
interpretation = ua_tools.interpret(ua_string)
print(f"Interpretation: {interpretation}")
# Most common user agent
most_common_ua = ua_tools.top_user_agent()
print(f"Most Common User Agent: {most_common_ua}")
# Top-n user agents
top_5_uas = ua_tools.top_n_user_agents(5)
print("Top 5 User Agents:")
for i, ua in enumerate(top_5_uas, 1):
print(f"{i}. {ua}")
License
This project is licensed under the Creative Commons Zero v1.0 Universal (CC0) license.
Acknowledgments
Thanks to willshouse.com, source of the useragents by prevalence listed in data.json
.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file user_agent_tools-0.1.0.tar.gz
.
File metadata
- Download URL: user_agent_tools-0.1.0.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c876b6e46090db45940fc435c59b705b60087b09710c9af4698123f28523f242 |
|
MD5 | 3222e2c58ecc25b707c2259be7227568 |
|
BLAKE2b-256 | c97ce5822131cae7d122ee4b472daf591ed2c247f9d97c73f659e8f860426bcd |
File details
Details for the file user_agent_tools-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: user_agent_tools-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 777281ca3495a05d7e6b7ada17e7d5f08349d0a028e218206400ff53fce8faed |
|
MD5 | 588b422a865ce3891479b0d02bbd095b |
|
BLAKE2b-256 | e086a29ec01d63e5c318f4f54b79de0e431e20f113bda4b3c298019e93f8ea5b |