UA generator
Generates random but realistic user agents (UAs) on a command line (or via API, if you like).
$ uagen mobile chrome
Mozilla/5.0 (Linux; Android 10; TAS-AN00) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.64 HuaweiBrowser/10.0.5.300 Mobile Safari/537.36
Use case
You want to:
- generate realistic-looking user agents with curl, wget, httpie etc
- stop tediously searching for, copying, and pasting user agent strings from long UA lists
- have realistic-looking HTTP requests using common user agent strings via curl and friends
- filter the UAs you choose depending on OS, platform (desktop, mobile, tablet), and browser
- refrain from checking the UA generator doco every single time to see if it's actually
--msie,--ie, or--iexplore.
Installation
$ pip install --user useragent-picker-cli
Alternatively, visit https://pypi.org/project/useragent-picker-cli/ to download the install files directly.
Once installed, the command you run is `uagen`.
Usage
uagen can be used by listing some filter criteria you'd like to use:
$ uagen chrome macos # Chrome on MacOS
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.116 Safari/537.36
$ uagen chrome osx # Chrome on MacOS again
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36
There are many aliases, so just try what makes sense to you and it will probably work. If not, submit an issue!
If you want something a little niche that's not in the supported keyword list, uagen will search through browser UAs as a fallback:
$ uagen trident
** 'trident' didn't match any known filters, looking for matching browser strings
Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
uagen simply outputs a single user agent matching your criteria. This can be combined with CLI HTTP tools like this:
$ curl --user-agent "$(uagen)" http://example.com
$ curl -v --user-agent "$(uagen nokia mobile)" http://example.com
...
> GET / HTTP/1.1
> Host: example.com
> User-Agent: Mozilla/5.0 (Linux; Android 10; Nokia 7 plus) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.93 Mobile Safari/537.360
You could also alias this for convenience:
$ alias uacurl='curl --user-agent "$(uagen)"
$ uacurl -v http://example.com
> GET / HTTP/1.1
> Host: example.com
> User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36
Since uagen respects weightings based on usage in the wild, if you ran it 1000 times, you'd get a rough % breakdown of UAs
like actual usage. TODO: weightings coming soon.
Programatic usage
ua-gen-cli is primarily designed for CLI use, but you can use it programatically too if you'd like:
from ua_gen.cli import UAGen
ua = UAGen()
print(ua.get_ua(["mobile"]))
print(ua.get_ua(["firefox", "desktop"]))
Data source
The user agent data file used lives at $HOME/.ua_cli_gen/enriched_ua_db.json, so feel free to have a look.
Acknowledgements
This project was inspired by and relies on data from https://github.com/intoli/user-agents.
Metadata
Release files for useragent-picker-cli 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| useragent_picker_cli-0.1.4-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for useragent_picker_cli-0.1.4-py2.py3-none-any.whl |
Release files / useragent_picker_cli-0.1.4-py2.py3-none-any.whl
| Download URL | useragent_picker_cli-0.1.4-py2.py3-none-any.whl |
|---|---|
| Size | 9.0 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
417d3736ef5b4dcb3043c6283c1c368f5e550249d02dc69f468ad6cd7e5711b6
|
|
BLAKE2b-256 checksum How to use checksums |
f1f5774dc89a81bd1490ca146ab6d085a99307165a119e06b0f16f76e45f0eaa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.4
|
Security for useragent-picker-cli 0.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.