2
嗨,所以我想解析一個網頁與HTML Agilty包來獲取圖像的src。這是頁面的結構。解析圖像src與HTML Agilty包
<div class="post_body">
<div style="text-align: center;">
<a href="http://www.engadget.com/2012/02/29/qualcomm-windows-8/">
<img src="http://www.blogcdn.com/www.engadget.com/media/2012/02/201202297192-1330536971.jpg" style="border-width: 0px; border-style: solid; margin: 4px;">
</a>
</div>
<div>
現在,我使用這個代碼來嘗試獲得SRC
HtmlWeb hw = new HtmlWeb();
HtmlDocument doc = hw.Load("http://www.engadget.com/2012/02/29/qualcomm-windows-8");
HtmlNode baseNode = doc.DocumentNode.SelectSingleNode("//div[@class='post_content permalink ']");
string Description = baseNode.SelectSingleNode("//div[@class='post_body']").InnerText.Replace("\n", "").Replace("\r", "").Trim();
string href = baseNode.SelectSingleNode("//div[@class='post_body']//img[@src]").InnerText;
但是字符串總是被返回null:/
任何想法,也許我有一個壞的XPath表達式?