爲什麼會出現此錯誤?傳遞HTML頁面的字符串並用HtmlAgilityPack擦除
「路徑中具有非法字符」 在
htmlDoc.Load(pageSource)
pageSource
是HTML頁面的一個字符串變量。我需要將頁面源作爲字符串傳遞,而不是作爲文件而不是URL。我該怎麼做呢?
Dim ids As New List(Of String)()
Dim pageSource = getHtml(url)
Dim htmlDoc As HtmlDocument = New HtmlDocument()
htmlDoc.OptionFixNestedTags = True
htmlDoc.Load(pageSource)
Dim s As HtmlNodeCollection = htmlDoc.DocumentNode.SelectNodes("//div/@id")
For Each div As HtmlNode In s
ids.Add(div.Id)
Next
@minitech如果刪除了C#標籤,你不必爲VB.NET – jcolebrand 2012-07-21 04:33:11
@jcolebrand格式化:我知道,但[tag:c#]對於讓人們知道C#答案是可以接受的很重要。 – Ryan 2012-07-21 04:34:04
@minitech你怎麼看?這是.NET,但仍需要針對原始問題的VB.NET進行量身定製。大多數編寫.NET代碼的人會掛斷一種語言,不知道如何在兩者之間進行轉換(來源:經驗) – jcolebrand 2012-07-21 04:35:24