标签:print useragent from ade actor 安装库 head header code
安装库获取随机的UserAgent的两种方法
# 获取随机的UA
‘‘‘
首先安装包
pip install fake_useragent
pip install faker
‘‘‘
# 方法一
from fake_useragent import UserAgent
ua = UserAgent()
headers = {‘User-Agent‘:ua.random}
print(headers)
# 方法二
from faker import Factory
f = Factory.create()
ua = f.user_agent()
print(ua)
标签:print useragent from ade actor 安装库 head header code
原文地址:https://www.cnblogs.com/HelloBytes/p/13179804.html