How can I retrieve and parse just the html returne

2019-07-30 09:49发布

I want to be able to programmatically (without it displaying in the browser) send an URL such as http://www.amazon.com/s/ref=nb_sb_noss_1?url=search-alias%3Daps&field-keywords=platypi&sprefix=platypi%2Caps&rh=i%3Aaps%2Ck%3Aplatypi" and get back in a string (or some more appropriate data type?) the html results of the page (the interesting part, anyway) so that I could parse that and reformat selected parts of it as matched text and images (which link to the appropriate page). I want to do this with Razor/Web Pages, if that makes any difference.

IOW, this is sort of a screen-scraping question, but really a "behind-the-screen" scraping.

Is it possible? How? A 100 point post-answer-bonus will be awarded to the (or the most helpful) answer.

1条回答
冷血范
2楼-- · 2019-07-30 10:51

Use the WebClient class (or .Net 4.5's better HttpClient class) to download the HTML, then use HTML AgilityPack to parse it

查看更多
登录 后发表回答