HTMLAgilityPack not recognising first element

29 Views Asked by At

I am trying to get the games schedule from site (https://www.espn.com/nba/schedule ).

The tables, in simplified terms, have the following structure:

<div class="ScheduleTables">
<div> Date </div>
<table class="Table"> ... </table>
</div>

The first table is not fetched - it is ignored. Instead, the table from the day following the latest one displayed on the page is fetched (this table is not displayed on the linked page, and I do not see it in the HTML code of the page). The element also contains a nested element displaying the date. The date always appears from the previous table instead of the correct one.

var web = new HtmlWeb();
var document = web.Load(StatsUrl);
var schedules = document.QuerySelectorAll("div").Where(d => d.HasClass("ScheduleTables"));
var tbodys = schedules.QuerySelectorAll("tbody");

This is my code that does not return correct elements. I've also tried document.DocumentNode.SelectNodes("//div[contains(@class, 'ScheduleTables')]") but the results were the same.

Thanks in advance!

0

There are 0 best solutions below