Skip to main content

A random user-agent generator

Project description

ua-generator

A random user-agent generator for Python >= 3.6

Features

  • No external user-agent list. No downloads.
  • Templates are hardcoded into the code.
  • Platform and browser versions are based on real releases.
  • Client hints (Sec-CH-UA fields).

Installing

pip3 install -U ua-generator

Basic usage

import ua_generator

ua = ua_generator.generate()
print(ua) # Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/15.2 Safari/604.1.38

Customization

There are three different parameters to the generate user-agent by the certain conditions.

device = ('desktop', 'mobile')
platform = ('windows', 'macos', 'ios', 'linux', 'android')
browser = ('chrome', 'edge', 'firefox', 'safari')

All of the parameters are optional, and the types can be choose multiple.

import ua_generator

ua = ua_generator.generate(device='desktop', browser='firefox')
print(ua.text) # Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:121.0.1) Gecko/20100101 Firefox/121.0.1
print(ua.platform) # macos
print(ua.browser) # firefox
print(ua.ch.brands) # "Not A(Brand";v="99"
print(ua.ch.mobile) # ?0
print(ua.ch.platform) # "macOS"
print(ua.ch.platform_version) # "14.0.1"

ua = ua_generator.generate(platform=('ios', 'macos'), browser='chrome')
print(ua.text) # Mozilla/5.0 (iPhone; CPU iPhone OS 17_0_2 like Mac OS X) AppleWebKit/537.36 (KHTML, like Gecko) CriOS/119.0.6045.176 Mobile/15E148 Safari/537.36
print(ua.platform) # ios
print(ua.browser) # chrome
print(ua.ch.brands) # "Not A(Brand";v="99", "Chromium";v="119", "Google Chrome";v="119"
print(ua.ch.mobile) # ?1
print(ua.ch.platform) # "iOS"
print(ua.ch.platform_version) # "17.0.2"

Author

Ekin Karadeniz (iamdual@icloud.com)

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

ua-generator-0.2.0.tar.gz (16.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ua_generator-0.2.0-py3-none-any.whl (22.5 kB view details)

Uploaded Python 3

File details

Details for the file ua-generator-0.2.0.tar.gz.

File metadata

  • Download URL: ua-generator-0.2.0.tar.gz
  • Upload date:
  • Size: 16.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for ua-generator-0.2.0.tar.gz
Algorithm Hash digest
SHA256 eb899a42d58402030e5194d27d4a2863d28959c5f9fff37d8337f019b02c4a11
MD5 991f349bb48bed04c948cb932a45c9b7
BLAKE2b-256 d3215f603faaad18a535004b3467d861e4085625b860b217d47d60a884590f6a

See more details on using hashes here.

File details

Details for the file ua_generator-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: ua_generator-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 22.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for ua_generator-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 683334f3d0851e32937fd266c69ee33f0844418e161fb94ab84498c7cd68af43
MD5 21914461a8ae79b4186f4cd09acc308e
BLAKE2b-256 5cc1cfb1570e7cfda66efbabf03edcb88307f720c5d98c62397d44cb94faa0bf

See more details on using hashes here.

Supported by

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