简体   繁体   English

HttpWebRequest返回与Web浏览器不同的结果

[英]HttpWebRequest returns different results than web browser

I am trying to crawl a web site and fetch its pages' data. 我正在尝试抓取一个网站并获取其网页的数据。 It all went well till one point where I started to get different data than the one coming in the view-source (the one I have expected). 这一切都很顺利,直到我开始获得不同于观察源(我预期的那个)的数据。 I am using html-agility-pack but also tried using HttpWebRequest, in order to change all it's headers, but no luck. 我正在使用html-agility-pack但也尝试使用HttpWebRequest,以便更改它的所有标题,但没有运气。 I know it isn't a JavaScript trick because of the data in the view source. 我知道这不是JavaScript技巧,因为视图源中的数据。 I hope someone has an idea to a possible explanation or solution. 我希望有人知道可能的解释或解决方案。

There are a lot of factors that could possibly affect the html sent to you by the server. 有很多因素可能会影响服务器发送给您的html。 I suggest you use a tool such as fiddler to inspect the request headers more closely. 我建议你使用fiddler这样的工具来更仔细地检查请求头。

From my experience the usual culprits in such problems are cookies and session information stored as hidden fields in the document and sent with each request as part of the request body. 根据我的经验,这些问题中常见的罪魁祸首是将cookie和会话信息存储为文档中的隐藏字段,并作为请求正文的一部分与每个请求一起发送。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM