Random request headers for local versions of browsers
Project description
这是一个本地版ua随机头, 不会出现请求超时等错误, 功能单一, 使用简单
更多精彩文章, 请关注 [ 不止于python ] 公众号
使用方法
from local_fake_useragent import UserAgent
# 获取所有浏览器的随机请求头
u = UserAgent()
# 获取chrome的随机请求头
u = UserAgent("chrome")
# 添加自定义请求头
c = {
"0": ["a", "b"]
}
u = UserAgent("0", add_custom_header=c)
print(u.rget)
# 支持的浏览器
print(UserAgent.BROWER)
测试用例
import requests
from local_fake_useragent import UserAgent
uas = UserAgent()
headers = {'User-agent': uas.rget}
url = 'https://www.baidu.com'
response = requests.get(url=url, headers=headers)
response.encoding = response.apparent_encoding
print(response.text)
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 Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for local_fake_useragent-1.1.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e38692a34f4c95babb020168c6a159cf1b16d845a4dd6e25d556fb3d5a7736d |
|
MD5 | b9919b6fd7059557ac4f5d6286791366 |
|
BLAKE2b-256 | 5c72c18bb633e8f21f34d8fe2a0342d2e15429d2eba5a6133cc88e3b7b9946fc |