WebClient.DownloadString() Not Producing Exact HTML

扶醉桌前 提交于 2019-12-24 19:25:55

问题


So here's the deal. I'm creating a spider bot for a website that scans all the product pages and records the product data. I'm using C# and the WebClient library to download the HTML string. The site I'm crawling must be specially made because the HTML that is received from WebClient.DownloadString() is different than the HTML that I get when I view the source of the HTML when visiting it on a browser. This seems intentional because the only info I can't get is the price.

Does anyone know a workaround for this problem or can anyone explain what is happening? Thanks.


回答1:


It is probably using the the user agent string to decide what content to send. The example here shows how to set the user agent header.



来源:https://stackoverflow.com/questions/2877286/webclient-downloadstring-not-producing-exact-html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!