我的如下C#htmlagilitypack XPATH回报System.NullReferenceException
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HtmlAgilityPack;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
HtmlWeb webClient = new HtmlWeb();
HtmlAgilityPack.HtmlDocument doc = webClient.Load("https://uk.finance.yahoo.com/q/hp?s=0001.HK");
string date = doc.DocumentNode.SelectSingleNode(@"/html/body/div/div/table/tbody/tr[2]/td[1]/table/tbody/tr/td/table/tbody/tr[2]/td[1]").InnerText;
Console.Write(date);
Console.ReadKey();
}
}
}
但是,Xpath的返回空值,我用XPATH帮手来检查代码,它是正确的(请参见附图)
任何人都可以给我一些想法吗?谢谢
对不起,我试过你的代码。它仍然返回null 希望有些机构可以添加更多评论 – wkcalvin