使用requests在向某个链接Post请求时,即使在Headers中撰写了User-Agent,但使用Fiddler抓包的结果显示在请求头的Client中,User-Agent仍然是Python-requests/2.10. , 仅仅是在Miscellaneous中加入了我设置的User-Agent一行,也没有获得想要的数据,怀疑是不是这个请求头没有设置好;
User-Agent: python-requests/2.10.0
Accept: text / html, application / xhtml + xml, application / xml;q = 0.9, image / webp, * / *;q = 0.8
Connection: keep - alive
Accept-Encoding: gzip, deflate
Accept - Encoding: gzip, deflate
Cache - Control: max - age = 0
Content - Length: 56
Content - Type: application / x - www - form - urlencoded
Upgrade - Insecure - Requests: 1
Accept - Language: zh - CN, zh;q = 0.8
User - Agent: Mozilla / 5.0(WindowsNT6.1;WOW64) AppleWebKit / 537.36(KHTML, likeGecko) Chrome / 51.0.2704.103Safari / 537.36
Content-Length: 116
Content-Type: application/x-www-form-urlencoded
请问如何用requests正确的改变User-Agent的值?
不知道你学python多久了.
我觉得这种问题你不应该来这里问,网上有很多例子,本站也有
Python 爬虫-模拟登录知乎-爬取拉勾网职位信息
python爬虫——requests模拟登入,模拟登入豆瓣
自己去看吧.