2017-08-24 121 views
0

这是误差(下面一行)无法找到的xpath返回null HTMLAgilityPack

Dim div As HtmlNode = doc.DocumentNode.SelectSingleNode(String.Format("//*[@id'requestKey']")) 

    'if the div is found, print the inner text' 
    If Not div Is Nothing Then 
     MsgBox(div.GetAttributeValue("value", "nu")) 

    End If 

End Function 

总是返回一个空值。

这是网站 https://www.footlocker.com/product/model:272681/sku:CP8683/adidas-originals-tubular-shadow-knit-mens/black/grey/

我使用HTMLagilitypack

回答

0

小心在字符串中引号和双引号。
你XPath是无效的,应该是这样的:

//*[@id='requestKey'] 

//*[contains(@id, 'requestKey')] 
+0

谢谢你,现在它的伟大工程 –