简体   繁体   English

Python request.headers与我在Chrome中看到的有所不同

[英]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.

相关问题 request.headers与request.environ - request.headers vs. request.environ 如何配置serverless.yml或AWS API网关或AWS Lambda处理程序以从POST请求读取request.header - How to configure serverless.yml or AWS API gateway or AWS lambda handler to read request.headers from POST request 我从Google API获得的邮件数大约有所不同。 与我在Gmail上看到的内容相比有10% - The message count I'm getting from Google API differs in approx. 10% from what I see on Gmail 如何在发送请求之前查看请求将包含哪些标头 - How to see what headers a request would contain before sending that request 我正在尝试抓取网站,但遇到了问题。 当我尝试抓取数据时,看起来 html 与我看到的不同 - I am trying to scrape website, but I encountered a problem. When I try to scrape data, it looks like the html differs from what I see on "如何使用 Python 从网络选项卡的特定请求的“请求标头”中获取信息?" - How can I fetch info from the "Request Headers" of a specific request from the network tab using Python? 使用urllib.request.urlopen返回空白,但是从Chrome浏览器中我可以看到响应中有数据 - Using urllib.request.urlopen returns blank but from Chrome I can see there is data in Response python requests.get(url) 超时但在浏览器(chrome)中有效; 如何为某个主机定制请求标头? - python requests.get(url) times out but works in browser (chrome); how can I tailor the request headers for a certain host? Python - request.get() 返回 200 - 但是存储在 HTML 上的信息与浏览器显示的不同。 试图刮掉 html。 雅虎财经 - Python - request.get() returns 200 - however the information stored on HTML differs from what browser shows. Trying to scrape html. Yahoo Finance 我从蟒蛇身上刮掉的东西和我从萤火虫身上看到的东西不一样 - What I scrape from python is not the same as what I see from firebug
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM