请问使用requests如何指定使用的User-agent

使用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的值?

阅读 19.4k
1 个回答
宣传栏