為什麼我會收到此錯誤?
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