0

When parsing the site https://holfuy.com/en/weather/1284 HtmlAgilityPack returns "-" for relevant data.

   string url = "https://holfuy.com/en/weather/1284";
    var web = new HtmlWeb();
    web.PreRequest += request =>
    {
        request.CookieContainer = new System.Net.CookieContainer();
        return true;
    };
    HtmlDocument doc = web.Load(url);

    string data = doc.DocumentNode.SelectNodes("//*[@id=\"j_pressure\"]")[0].InnerText;
    Console.WriteLine(data);

What is the reason behind this?

1 Answers1

1

It seems that data is dynamically loaded into page and if you need to parse it you need to hook real browser, through for example Selenium and use one of available drivers there or if you don't want to include entire Selenium just hook some headless browser like phantom.js directly. Once you do it, just set some small delay for data to render, load page and parse.

You can see more information here: Running Scripts in HtmlAgilityPack

MarKhan
  • 26
  • 4