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 (X11; Ubuntu; Linux x86_64; rv:85.0) Gecko/20100101 Firefox/85.0
print(ua.platform)  # linux
print(ua.browser)   # firefox
print(ua.ch.brands) # " Not A;Brand";v="99"
print(ua.ch.mobile) # ?0

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

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.1.7.tar.gz (14.5 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.1.7-py3-none-any.whl (21.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ua-generator-0.1.7.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.5 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/18.0.1 rfc3986/2.0.0 colorama/0.4.3 CPython/3.8.10

File hashes

Hashes for ua-generator-0.1.7.tar.gz
Algorithm Hash digest
SHA256 9a7417a392bc21a81c7c834d3d6c78d9c01506895ff62404021390242e2963c1
MD5 9bf596ec83c82bfab321485ff3167b6c
BLAKE2b-256 fc4dde857a507ad120214e6fd8ff8f8cc4fdd0861cd347a89379370ff6489a7f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ua_generator-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 21.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.5 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/18.0.1 rfc3986/2.0.0 colorama/0.4.3 CPython/3.8.10

File hashes

Hashes for ua_generator-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 9c20742398659b550ab5f07a10c91611099c205eff8cb02dacd16790eb421dc9
MD5 8f887ddde98702fde59ff37bbb678903
BLAKE2b-256 4394dc7218b796b0715aec86ee629c0b5c10641c44836fe3971ec6b20491daf1

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