Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

user_agent_tools-0.1.0.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

user_agent_tools-0.1.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

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

Hashes for user_agent_tools-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c876b6e46090db45940fc435c59b705b60087b09710c9af4698123f28523f242
MD5 3222e2c58ecc25b707c2259be7227568
BLAKE2b-256 c97ce5822131cae7d122ee4b472daf591ed2c247f9d97c73f659e8f860426bcd

See more details on using hashes here.

File details

Details for the file user_agent_tools-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for user_agent_tools-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 777281ca3495a05d7e6b7ada17e7d5f08349d0a028e218206400ff53fce8faed
MD5 588b422a865ce3891479b0d02bbd095b
BLAKE2b-256 e086a29ec01d63e5c318f4f54b79de0e431e20f113bda4b3c298019e93f8ea5b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page