素衣清颜淡若尘

Python中通过fake_useragent生成随机UserAgent

电脑版发表于:2020/8/6 9:08

fake_useragent第三方库,来实现随机请求头的设置;

GitHub               ---> https://github.com/hellysmile/fake-useragent

安装                    ---> pip/pip3 install fake-useragent(安装方式看你pip的版本)

查看useragent   ---> http://fake-useragent.herokuapp.com/browsers/0.1.5


简单的使用:

from fake_useragent import UserAgent

ua = UserAgent()
print(ua.ie)   #随机打印ie浏览器任意版本
print(ua.firefox) #随机打印firefox浏览器任意版本
print(ua.chrome)  #随机打印chrome浏览器任意版本
print(ua.random)  #随机打印任意厂家的浏览器
UserAgent(verify_ssl=False).random


关于TNBLOG
TNBLOG,技术分享。技术交流:群号677373950
ICP备案 :渝ICP备18016597号-1
App store Android
精彩评论
{{item.replyName}}
{{item.content}}
{{item.time}}
{{subpj.replyName}}
@{{subpj.beReplyName}}{{subpj.content}}
{{subpj.time}}
猜你喜欢