我想从这个站点下载每日照片,但我不能使用它的网址,因为它每天都在变化。
有没有任何方法从网站下载对象使用网页网址和XPath?我试图在WebClient中找到一些方法,但没有运气。
发布于 2015-10-23 12:05:33
我用HTML敏捷包评论的一个例子:
WebClient client = new WebClient();
string resource = client.DownloadString("http://photography.nationalgeographic.com/photography/photo-of-the-day/");
HtmlAgilityPack.HtmlDocument html = new HtmlAgilityPack.HtmlDocument();
html.LoadHtml(resource);
var imgDiv = html.DocumentNode.SelectSingleNode("//*[contains(@class,'primary_photo')]");
var imgSrc = imgDiv.SelectSingleNode("//img/@src");
string relativePath = imgSrc.GetAttributeValue("src", "");https://stackoverflow.com/questions/33301484
复制相似问题