User-Agent changing library for Python.
Project description
useragent-changer
A library for changing user agents in order to verify the operation of web systems.
Features
- This package contains User-Agent data for a total of 19,381 for the platforms listed below.
- Android (2,144), Chrome (4,996), Edge (91), Firefox (2,132), iPad (45), iPhone (750), Mac (1,739), Safari (4,952), Windows (2,532)
- User-Agent corresponding to each platform is described in 9 CSV files in the data folder in this package.
- Supports Python 3.x
Installation
Enter one of the following two commands:
pip3 install useragent-changer
pip3 install git+https://github.com/gitmori/useragent-changer
Downloads
Usage
from useragent_changer import UserAgent
ua = UserAgent('android')
print(ua.set())
# Dalvik/2.1.0 (Linux; U; Android 10; ASUS_Z01RD Build/QKQ1.191008.001)
ua = UserAgent('iphone')
print(ua.set())
# Mozilla/5.0 (iPhone; CPU iPhone OS 12_5_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.2 Mobile/15E148 Safari/604.1
ua = UserAgent('ipad')
print(ua.set())
# Mozilla/5.0 (iPad; CPU OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/94.0.4606.76 Mobile/15E148 Safari/604.1
ua = UserAgent('windows')
print(ua.set())
# Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 10.0; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729)
ua = UserAgent('mac')
print(ua.set())
# Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:49.0) Gecko/20100101 Firefox/49.0
ua = UserAgent('chrome')
print(ua.set())
# Mozilla / 5.0 (Windows NT 10.0; Win64; x64) AppleWebKit / 537.36 (KHTML, like Gecko) Chrome / 74.0.3729.169 Safari / 537.36
ua = UserAgent('edge')
print(ua.set())
# Mozilla/5.0 (Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.9200
ua = UserAgent('safari')
print(ua.set())
# Mozilla/5.0 (BlackBerry; U; BlackBerry 9900; ja) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.1.0.523 Mobile Safari/534.11+
ua = UserAgent('firefox')
print(ua.set())
# Dalvik/2.1.0 (Linux; U; Android 10; ASUS_Z01RD Build/QKQ1.191008.001)
ua = UserAgent()
print(ua.set())
# Get a random User-Agent
Test
If you don't have Selenium installed, run the following command: pip3 install selenium
from selenium.webdriver import ChromeOptions, Chrome
from useragent_changer import UserAgent
from time import sleep
PLATFORM= 'firefox'
URL = 'https://develop.tools/env-variable/'
ua = UserAgent(PLATFORM)
options = ChromeOptions()
options.add_argument('--ignore-certificate-errors')
options.add_argument('--user-agent=' + ua.set())
driver = Chrome(options=options)
driver.get(URL)
SECONDS = 5
sleep(SECONDS)
driver.quit()
Changelog
- 0.1.1 August 02, 2023
- First push
- 0.3.2 September 12, 2023
- Fixed comments in module file
Author
Yuki Moriya (gitmori)
ym19820219@gmail.com
Licence
Copyright (c) 2023 Yuki Moriya
This software is released under the MIT License, see LICENSE.txt.
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
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 useragent_changer-0.3.2.tar.gz.
File metadata
- Download URL: useragent_changer-0.3.2.tar.gz
- Upload date:
- Size: 148.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e69b0f95b62a9a5e15f7b718c75ad238eb827b6dfd238d34ef212931cbec3d94
|
|
| MD5 |
b1a01ded35d6b6fa9ffa04cdd3ab195c
|
|
| BLAKE2b-256 |
c96867b2957b5ec1b196401e01c4a87cc146e5a9035960c1be43e006681e08d1
|
File details
Details for the file useragent_changer-0.3.2-py3-none-any.whl.
File metadata
- Download URL: useragent_changer-0.3.2-py3-none-any.whl
- Upload date:
- Size: 158.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03ff69c6c1ebbba46fe12a9b4c68df58533530b095d921464b25df49be39a3d1
|
|
| MD5 |
584a5fd0f5eecab2507b63e19af712bc
|
|
| BLAKE2b-256 |
3876b2799ef92a77fca35ae5da12c2857bfb40cf20f30c7c0a4762bf2457bb05
|