Не могу получить столбцы таблицы при парсинге сайта
using System;
using System.Linq;
using System.Net.Http;
namespace Parser
{
class Program
{
static void Main(string[] args)
{
var result = Parsing(url: "https://ru.wikipedia.org/wiki/%D0%A1%D0%BF%D0%B8%D1%81%D0%BE%D0%BA_%D0%BA%D0%B8%D0%BD%D0%BE%D1%82%D0%B5%D0%B0%D1%82%D1%80%D0%BE%D0%B2_%D0%9C%D0%BE%D1%81%D0%BA%D0%B2%D1%8B");
}
private static object Parsing(string url)
{
try
{
using(HttpClientHandler hdl = new HttpClientHandler { AllowAutoRedirect = false, AutomaticDecompression = System.Net.DecompressionMethods.Deflate | System.Net.DecompressionMethods.GZip | System.Net.DecompressionMethods.None})
{
using (var client = new HttpClient(hdl))
{
using (HttpResponseMessage response = client.GetAsync(url).Result)
{
if (response.IsSuccessStatusCode)
{
var html = response.Content.ReadAsStringAsync().Result;
if (!string.IsNullOrEmpty(html))
{
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(html);
var table = doc.DocumentNode.SelectSingleNode(".//div[@class='mw-body']//div[@class='vector-body']//div[@class='mw-body-content mw-content-ltr']//div[@class ='mw-parser-output']//table[@class='wikitable']//tbody");
if (table != null)
{
var rows = table.SelectNodes(".//tr");
if (rows != null)
{
foreach(var row in rows)
{
var cells = row.SelectNodes(".//td");
if (cells != null && cells.Count > 0)
{
Console.WriteLine(cells.Select(c => c.InnerText));
}
}
}
}
}
}
}
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
return null;
}
}
}
Как бы я не пытался, в cells всегда получаю null. Почему так происходит и как исправить? Заранее спасибо.