Fake useragent randomly generates a useragent for fetching a webpage without a browser.
Project description
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 asyncio and aiohttp to improve fetching speed
- taking advantage of Xpath to improve parsing speed
- changing random choice algorithm to improve random choice speed
Usage
On terminal, enter fakeua
In python script, just import the function. Every time you run your python script, the user agent is randomly chosen, so each time the value is different.
from fake_user_agent.main import user_agent
# Not specify a browser:
ua = user_agent()
# Specify a browser to randomly choose from:
ua = user_agent("chrome")
# Using tempfile takes less than 0.001s from the second time.
# Not using it takes less than 3s because of fetching data on the web each time.
# By default tempfile is used, you can turn it off by:
ua = user_agent(use_temfile=False)
# Remove tempfile
rm_tempfile()
Remove tempfile with terminal command on Linux or MacOS, replace var
to respective folder name on Windos
bash
find /var/ -name "fake_useragent*" -type f -exec rm {} ;
# Installation
```python
pip install fake_user_agent
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
fake_user_agent-0.0.7.tar.gz
(52.3 kB
view hashes)
Built Distribution
Close
Hashes for fake_user_agent-0.0.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6e2390af05cb8f46c1017410a88ef1c09b8efcc1778629c19d6e022017c8950 |
|
MD5 | 97fa7263b0f6ebc40d08ba014f74a95d |
|
BLAKE2b-256 | 8068a836149fac8d8f6a24f6803d45b7f22444c8a1198e23a4f6488dbf46686c |