2017-08-24 122 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

謝謝你,現在它的偉大工程 –