0
for (int i = 0; i < numberoflinks; i++)
{
string downloadString = client.DownloadString(mainlink+i+".html");
var document = new HtmlWeb().Load(url);
var urls = document.DocumentNode.Descendants("img")
.Select(e => e.GetAttributeValue("src", null))
.Where(s => !String.IsNullOrEmpty(s))
}
問題是,HtmlWeb()。加載需要一個HTML網址,但我想加載字符串downloadString已經在裏面的HTML內容。我怎樣才能提取使用htmlagilitypack從字符串與HTML內容鏈接?
更新:
我現在嘗試這樣做:
for (int i = 0; i < numberoflinks; i++)
{
string downloadString = client.DownloadString(mainlink+i+".html");
HtmlAgilityPack.HtmlDocument document = new HtmlAgilityPack.HtmlDocument();
document.Load(downloadString);
var urls = document.DocumentNode.Descendants("img")
.Select(e => e.GetAttributeValue("src", null))
.Where(s => !String.IsNullOrEmpty(s));
}
但我就行了越來越異常:路徑
document.Load(downloadString);
非法字符
我」什麼想要做是從每一個環節下載/提取所有.JPG圖像。 沒有先下載鏈接到硬盤,但將內容下載到一個字符串提取物在這個網站以.jpg結尾的所有圖片鏈接然後下載JPG的。