Ошибка в парсере сайта на C#. Запускаю код в VS Studio с использованием HtmlAgilityPack, ошибка 'Expression must evaluate to a node-set.' Помогите
Помогите, пожалуйста, как правильно указать путь к html-классам сайта? (Хочу запарсить все таблицы с названиями команд и отдельно с коэффициентами. Уже месяц пытаюсь, не могу и не знаю как правильно указать путь к таблицам (46, 51, 54, 57, 63 строки) Если что, ссылка на сам сайт: https://parisportif.pmu.fr/home/wrapper/dashboard?lang=fr&activeSportId=1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
namespace cSharpWebParserV04
{
class Program
{
static void Main(string[] args)
{
Dictionary<string, List<List<string>>> result12 = Parsing12(url12: "https://parisportif.pmu.fr/");
if (result12 != null)
{
foreach (var item12 in result12)
{
Console.WriteLine("-----------------------------------------");
Console.WriteLine(item12.Key);
Console.WriteLine("-----------------------------------------");
item12.Value.ForEach(r => Console.WriteLine(string.Join("\t", r)));
Console.WriteLine("-----------------------------------------\n");
}
}
Console.ReadKey();
}
private static Dictionary<string, List<List<string>>> Parsing12(string url12)
{
try
{
Dictionary<string, List<List<string>>> result1 = new Dictionary<string, List<List<string>>>();
using (HttpClientHandler hdl = new HttpClientHandler { AllowAutoRedirect = false, AutomaticDecompression = System.Net.DecompressionMethods.Deflate | System.Net.DecompressionMethods.GZip | System.Net.DecompressionMethods.None })
{
using (var clnt = new HttpClient(hdl))
{
using (HttpResponseMessage resp = clnt.GetAsync(url12).Result)
{
if (resp.IsSuccessStatusCode)
{
var html = resp.Content.ReadAsStringAsync().Result;
if (!string.IsNullOrEmpty(html))
{
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(html);
var tables = doc.DocumentNode.SelectNodes(".//div[@class='sb-event-list__main']//div[@class='sb-event-list__container']//div[@class]//");// ЗАМЕНИТЬ КЛАСС
if (tables != null && tables.Count > 0)
{
foreach (var table in tables)
{
var titleNode = table.SelectSingleNode(".//div[@class='ng-star-inserted']");
if (titleNode != null)
{
var tbl = table.SelectSingleNode(".//div[@class='ng-star-inserted']//table");
if (tbl != null)
{
var rows = tbl.SelectNodes(".//ss-events-list-event");
if (rows != null && rows.Count > 0)
{
var res = new List<List<string>>();
foreach (var row in rows)
{
var cells = row.SelectNodes(".//span");
if (cells != null && cells.Count > 0)
{
res.Add(new List<string>(cells.Select(c => c.InnerText)));
}
}
result1[titleNode.InnerText] = res;
}
}
}
}
return result1;
}
else
{
Console.WriteLine("No tables");
}
}
}
}
}
}
}
catch (Exception ex) { Console.WriteLine(ex.Message); }
return null;
}
}
}