[英]Python request.headers differs from what I see in Chrome
Just wondering if anyone could explain why I navigate to a webpage using Chrome and the request headers include Accept, Accept-Encoding, Accept-Language, Connection, Cookie, Host, Referer, Upgrade-Insecure-Request, and User-Agent but when I make a request via Python and print request.headers it only returns Connection, Accept-Encoding, Accept, and User-Agent even if I set the User-Agent to the same one I see in Chrome. 我只是想知道是否有人可以解释为什么我使用Chrome浏览到网页并且请求标头包括接受,接受编码,接受语言,连接,Cookie,主机,引荐来源,不安全升级请求和用户代理,但是当我通过Python发出请求并打印request.headers,即使我将User-Agent设置为我在Chrome中看到的相同名称,它也仅返回Connection,Accept-Encoding,Accept和User-Agent。 Also I'm wondering if it's possible to return those request headers I see in Chrome rather than those I see in Python. 我也想知道是否有可能返回我在Chrome中看到的那些请求标头,而不是在Python中看到的那些请求标头。 Thank you. 谢谢。
Your using two different libraries (Chrome's internal http library and requests
). 您使用两个不同的库(Chrome的内部http库和requests
)。 It's very rare for two unrelated libraries to send the same set of headers, especially when one is from a browser. 两个不相关的库发送相同的头文件集非常罕见,尤其是当一个来自浏览器时。 You could manually set those headers in requests
but I'm not sure what you're trying to do 您可以在requests
手动设置这些标头,但是我不确定您要做什么
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.