Randomly generate a valid useragent for faking a browser.
Supported browsers are: "chrome", "edge", "firefox", "safari", and "opera" (case insensitive).
## As a binary
```bash
fakeua # randomize a useragent (using cache by default)
fakeua [browser] # randomize a useragent of a specified browser
fakeua [browser] --debug # randomize a useragent in debug mode
fakeua [browser] --nocache # randomize a useragent by fetching the web
fakeua [browser] --cache # randomize a useragent by using cache other than the default one
fakeua --load <cache_path> # load up-to-date useragent versions as cache to specified file path
fakeua --remove <cache_path> # remove cache at specified file path
fakeua --version # print the current version of the program
```
## As a library
```python
# No error handling is needed.
# The following functions return a valid randomized useragent definitely.
# Resort to a fixed useragent in the event of an error when reading cache
# to avoid breaking the caller. In such case, turn on logging debug mode to inspect.
# `CACHE_FILE` defaults to `$HOME/.cache/fakeua/fake_useragent.json`.
# a different cache file is supported, which can be generated by:
# 1. running on terminal: fakeua --load <cache_path>
# 2. calling in script: `await dump(cache_path)`
# For non-async caller:
from fake_user_agent import user_agent
ua = user_agent(browser=None, use_cache=True, cache_path=CACHE_FILE)
# For async caller:
from fake_user_agent import aio_user_agent
ua = await aio_user_agent(browser=None, use_cache=True, cache_path=CACHE_FILE)
```
## Install & Uninstall
```bash
pip install fake_user_agent
pip uninstall -r requirements.txt -y
rm -rf $HOME/.cache/fakeua
# within the project
make install
make uninstall
make clean_cache
```
Raw data
{
"_id": null,
"home_page": null,
"name": "fake_user_agent",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "python, browser, useragent, User-Agent, header",
"author": null,
"author_email": "Kate Wang <kate.wang2018@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/11/a6/165a1013066c70efa5347d210fad7a2b44c2df53591524cc3bee746f01d2/fake_user_agent-2.3.9.tar.gz",
"platform": null,
"description": "Randomly generate a valid useragent for faking a browser.\n\nSupported browsers are: \"chrome\", \"edge\", \"firefox\", \"safari\", and \"opera\" (case insensitive).\n\n## As a binary\n```bash\nfakeua # randomize a useragent (using cache by default)\nfakeua [browser] # randomize a useragent of a specified browser\nfakeua [browser] --debug # randomize a useragent in debug mode\nfakeua [browser] --nocache # randomize a useragent by fetching the web\nfakeua [browser] --cache # randomize a useragent by using cache other than the default one\nfakeua --load <cache_path> # load up-to-date useragent versions as cache to specified file path\nfakeua --remove <cache_path> # remove cache at specified file path\nfakeua --version # print the current version of the program\n```\n\n## As a library\n```python\n# No error handling is needed.\n# The following functions return a valid randomized useragent definitely.\n# Resort to a fixed useragent in the event of an error when reading cache\n# to avoid breaking the caller. In such case, turn on logging debug mode to inspect.\n# `CACHE_FILE` defaults to `$HOME/.cache/fakeua/fake_useragent.json`.\n# a different cache file is supported, which can be generated by:\n# 1. running on terminal: fakeua --load <cache_path>\n# 2. calling in script: `await dump(cache_path)`\n\n# For non-async caller:\nfrom fake_user_agent import user_agent\nua = user_agent(browser=None, use_cache=True, cache_path=CACHE_FILE)\n\n# For async caller:\nfrom fake_user_agent import aio_user_agent\nua = await aio_user_agent(browser=None, use_cache=True, cache_path=CACHE_FILE)\n```\n\n## Install & Uninstall\n```bash\npip install fake_user_agent\npip uninstall -r requirements.txt -y\nrm -rf $HOME/.cache/fakeua\n\n# within the project\nmake install\nmake uninstall\nmake clean_cache\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "Randomly generate a valid useragent for faking a browser.",
"version": "2.3.9",
"project_urls": {
"Source": "https://github.com/KateWang2016/fake_user_agent"
},
"split_keywords": [
"python",
" browser",
" useragent",
" user-agent",
" header"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "26f750e5357c2605228bda9f64b719940bd380357893612f1ca54af0d5fba2a1",
"md5": "6612770b2b403d6d10b4195d5f0133a4",
"sha256": "bbf3dc2b37dea6d01b41c872c115f48f241888112a44d50540412d0c1b4e29dd"
},
"downloads": -1,
"filename": "fake_user_agent-2.3.9-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6612770b2b403d6d10b4195d5f0133a4",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 5593,
"upload_time": "2024-07-09T03:52:59",
"upload_time_iso_8601": "2024-07-09T03:52:59.627914Z",
"url": "https://files.pythonhosted.org/packages/26/f7/50e5357c2605228bda9f64b719940bd380357893612f1ca54af0d5fba2a1/fake_user_agent-2.3.9-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "11a6165a1013066c70efa5347d210fad7a2b44c2df53591524cc3bee746f01d2",
"md5": "ac0131df08b7f765d99e339b8bd026e0",
"sha256": "f6fbb2c657b94d547039a5ef1f8240162c54a24f5497aaf24273ab669197d4f4"
},
"downloads": -1,
"filename": "fake_user_agent-2.3.9.tar.gz",
"has_sig": false,
"md5_digest": "ac0131df08b7f765d99e339b8bd026e0",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 5112,
"upload_time": "2024-07-09T03:53:02",
"upload_time_iso_8601": "2024-07-09T03:53:02.186441Z",
"url": "https://files.pythonhosted.org/packages/11/a6/165a1013066c70efa5347d210fad7a2b44c2df53591524cc3bee746f01d2/fake_user_agent-2.3.9.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-09 03:53:02",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "KateWang2016",
"github_project": "fake_user_agent",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "aiohttp",
"specs": [
[
"==",
"3.9.5"
]
]
},
{
"name": "aiosignal",
"specs": [
[
"==",
"1.3.1"
]
]
},
{
"name": "attrs",
"specs": [
[
"==",
"23.2.0"
]
]
},
{
"name": "fake_user_agent",
"specs": [
[
"==",
"2.3.9"
]
]
},
{
"name": "frozenlist",
"specs": [
[
"==",
"1.4.1"
]
]
},
{
"name": "idna",
"specs": [
[
"==",
"3.7"
]
]
},
{
"name": "lxml",
"specs": [
[
"==",
"5.2.2"
]
]
},
{
"name": "multidict",
"specs": [
[
"==",
"6.0.5"
]
]
},
{
"name": "yarl",
"specs": [
[
"==",
"1.9.4"
]
]
}
],
"lcname": "fake_user_agent"
}