安装库获取随机的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)