问题
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