Randomly generate a fake useragent.
This project's idea is inspired by fake-useragent. I rewrote the whole codes in order to boost performance by:
- using
asyncioandaiohttpto improve fetching speed - taking advantage of
Xpathto improve parsing speed - changing random choice algorithm to improve random choice speed
Supported browsers are: chrome, edge, firefox, safari, and opera. Browser name is case insensitive. Some other possible spellings of each browser are mapped to the right one (e.g. "ie" -> "edge", "google" -> "chrome").
Usage
On your terminal, just simply enter fakeua
In your python script, just import the function. Every time you run the script, the useragent value will be different.
from fake_user_agent import user_agent
# Not specify a browser:
ua = user_agent()
# Specify a browser to randomly choose from:
ua = user_agent("chrome")
# It takes < 2s for the first run based on my 200M bandwith, including fetching, parsing, and writing cache.
# Using tempfile by default, it takes < 0.01s starting from the second time.
# You can specify not using tempfile, and it will take < 1s to run, including fetching and parsing:
ua = user_agent(use_tempfile=False)
# If there is an async function needing a useragent in your script,
# don't put `user_agent()` in your async function, put it above instead.
# Remove tempfile in a python script.
# May need `sudo python yourscript.py` for Linux.
from fake_user_agent import rm_tempfile
rm_tempfile()
Other usages on terminal
# Set to get a useragent in debug mode
fakeua <browser or omit> --debug
# Set to get a useragent without local caching
fakeua <browser or omit> --nocache
# Remove cache from tempfile folder
fakeua --remove
# Print the current version of the program
fakeua --version
Installation
pip install fake_user_agent
Metadata
Release files for fake_user_agent 2.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fake_user_agent-2.0.4.tar.gz | 145.0 kB | Without provenance | Details for fake_user_agent-2.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fake_user_agent-2.0.4-py3-none-any.whl | Python 3 | none | any | Details for fake_user_agent-2.0.4-py3-none-any.whl |
Total release size: 152.6 kB
Release files / fake_user_agent-2.0.4.tar.gz
| Download URL | fake_user_agent-2.0.4.tar.gz |
|---|---|
| Size | 145.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
068db5259ec42569126618dd790493ee2893c12c64cf0e48394c2ca3a8d988ad
|
|
BLAKE2b-256 checksum How to use checksums |
119c9ca7965a49d43d126db547a11573c0fb0b5c43c6bdb141f5825186f7be2c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.25.1
|
Release files / fake_user_agent-2.0.4-py3-none-any.whl
| Download URL | fake_user_agent-2.0.4-py3-none-any.whl |
|---|---|
| Size | 7.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8c1dbfe31fc3a5cf2191a3a88439dd451fb3b3800678a14d1ce1b14f13edc84a
|
|
BLAKE2b-256 checksum How to use checksums |
944bd8e98288fba5c94ef7e029445e9280618ec7dd6dd15b7beccd696afbecc0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.25.1
|
Security for fake_user_agent 2.0.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.