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
Installation
pip install user-agent-tools
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.1.tar.gz
.
File metadata
- Download URL: user_agent_tools-0.1.1.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9178a19d89b96c52ff201f58b4009a6f40bf0c74b8cb97d8307ea1eb1438cc32 |
|
MD5 | e20f04d6efcda29022cfc048c5fafb37 |
|
BLAKE2b-256 | c24d6088d7eea2554d24d84a206f301ea71133309d0621447ff3f20b0b5a1db6 |
File details
Details for the file user_agent_tools-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: user_agent_tools-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.5 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 | e444806b08087ea2e26b126468727a20f9fdd4eede2d71e4f9316f5ef3962fe9 |
|
MD5 | 9d7b6aab8e6c26ba9fee77c30302f267 |
|
BLAKE2b-256 | 4caf470db94e9bdd7e46b55ecfdda0ae38b5247b567775d6f91b3a506b375ffe |