Skip to main content

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.

Release files for user-agent-tools 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for user-agent-tools 0.1.1
File Size Uploaded
user_agent_tools-0.1.1.tar.gz 6.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for user-agent-tools 0.1.1
File Interpreter ABI Platform
user_agent_tools-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 12.6 kB

Release files / user_agent_tools-0.1.1.tar.gz

Download URL user_agent_tools-0.1.1.tar.gz
Size 6.1 kB
Tags Source
SHA-256 checksum
How to use checksums
9178a19d89b96c52ff201f58b4009a6f40bf0c74b8cb97d8307ea1eb1438cc32
BLAKE2b-256 checksum
How to use checksums
c24d6088d7eea2554d24d84a206f301ea71133309d0621447ff3f20b0b5a1db6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.12

Release files / user_agent_tools-0.1.1-py3-none-any.whl

Download URL user_agent_tools-0.1.1-py3-none-any.whl
Size 6.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e444806b08087ea2e26b126468727a20f9fdd4eede2d71e4f9316f5ef3962fe9
BLAKE2b-256 checksum
How to use checksums
4caf470db94e9bdd7e46b55ecfdda0ae38b5247b567775d6f91b3a506b375ffe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.12

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page