我有这个网址的{HtmlDocument www.vipme.com/clothing_c900027 因为他们的网站包含编码字符 这是我的代码
Dim myHtmlDom As HtmlDocument = GetHtmlDocument(requestUrl, item.cookie, "refer", item.pageEncoding)
Dim myProdDom As HtmlNodeCollection = myHtmlDom.DocumentNode.SelectNodes(item.prodPath)
For Each inode As HtmlNode In myProdDom
Dim newProd As New Product()
If (String.IsNullOrEmpty(item.urlPath)) Then
newProd.Url = inode.GetAttributeValue(item.urlAttri, "").Trim()
Else
newProd.Url = inode.SelectSingleNode(item.urlPath).GetAttributeValue(item.urlAttri, "").Trim
newProd.Url = Web.HttpUtility.UrlDecode(inode.SelectSingleNode(item.urlPath).GetAttributeValue(item.urlAttri, "").Trim)
End If
答案 0 :(得分:0)
我最终将UrlDecode更改为htmldecode方法:
decodeStr = inode.SelectSingleNode(item.urlPath).GetAttributeValue(item.urlAttri, "")
newProd.Url = Web.HttpUtility.HtmlDecode(decodeStr).Trim()
并且效果很好