我刚刚下载了HTMLAgilityPack,但是文档中没有任何示例。
我正在寻找一种从网站下载所有图片地址的方法,而不是实际的图片文件。
<img src="blabalbalbal.jpeg" />
我需要提取每个img标签的源代码。我只是想了解这个库能提供什么功能。大家都说这是最适合这项工作的最佳工具。
public void GetAllImages()
{
WebClient x = new WebClient();
string source = x.DownloadString(@"http://www.google.com");
HtmlAgilityPack.HtmlDocument document = new HtmlAgilityPack.HtmlDocument();
document.Load(source);
//I can't use the Descendants method. It doesn't appear.
var ImageURLS = document.desc
.Select(e => e.GetAttributeValue("src", null))
.Where(s => !String.IsNullOrEmpty(s));
}