HtmlAgilityPack scraping - extracting specific nodes from html document

c# html html-agility-pack web-scraping xpath


Apologies in advance if this has already been answered(if so please point me to right location), I searched here, web, youtube and so on for two days and still haven't founnd an answer.

I would like to extract some data from following url:;

I am trying to get all event names for the day(1st one is: Ho Kwan Kit/Wong Chun Ting — Fan Zhendong/Xu Xin and all others after it). When I inspect that element I can see this part of html:

<div class="content-results-data__event"><span>Ho Kwan Kit/Wong Chun Ting — Fan Zhendong/Xu Xin</span></div>

I was thinking of getting all div's with class="content-results-data__event" and than get inner text from those div's. Every time I run my code I get zero results. Why am I not getting any nodes when I can see that div's with such class exist and how can I get all events (if I learn how to do that I could get other info which I need from this site). Here is my code (have to say I am fairly new to this).

public partial class Scrapper : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)
        List<string> Events = new List<string>();
        HtmlWeb web = new HtmlWeb();
        HtmlDocument doc = NewMethod(web);
        var Nodes = doc.DocumentNode.SelectNodes(xpath: "//div[@class='content - results - data__event'']").ToList();

        foreach (var item in Nodes)

        GridView1.DataSource = Events;


    private static HtmlDocument NewMethod(HtmlAgilityPack.HtmlWeb web)
        return web.Load(";");


11/19/2017 10:52:32 PM

Accepted Answer

Here is how to get the HTML for one day of matches using Selenium. Rest is HtmlAgilityPack. The site uses self signed certificates so I had to configure the driver to accept self signed certificates. Have fun.

        var ffOptions = new FirefoxOptions();
        ffOptions.BrowserExecutableLocation = @"C:\Program Files (x86)\Mozilla Firefox\firefox.exe";
        ffOptions.LogLevel = FirefoxDriverLogLevel.Default;
        ffOptions.Profile = new FirefoxProfile { AcceptUntrustedCertificates = true };
        var service = FirefoxDriverService.CreateDefaultService();
       var driver = new FirefoxDriver(service, ffOptions, TimeSpan.FromSeconds(120));

        string url = ";"; //remember to update the date accordingly.

11/20/2017 12:37:12 AM

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow