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
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
ua-generator-0.2.0.tar.gz
(16.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb899a42d58402030e5194d27d4a2863d28959c5f9fff37d8337f019b02c4a11
|
|
| MD5 |
991f349bb48bed04c948cb932a45c9b7
|
|
| BLAKE2b-256 |
d3215f603faaad18a535004b3467d861e4085625b860b217d47d60a884590f6a
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
683334f3d0851e32937fd266c69ee33f0844418e161fb94ab84498c7cd68af43
|
|
| MD5 |
21914461a8ae79b4186f4cd09acc308e
|
|
| BLAKE2b-256 |
5cc1cfb1570e7cfda66efbabf03edcb88307f720c5d98c62397d44cb94faa0bf
|