using System.Threading.Tasks;
public static Task<IDocument> ToDocument(this string html)
=> BrowsingContext.New().OpenAsync(x => x.Content(html));
private static readonly HttpClient client = new() { BaseAddress = new Uri("http://bocchi-rus.ru/") };
static async Task Main(string[] args)
public static async Task PrintAsync()
foreach (var product in await GetProductsAsync())
var path = product.QuerySelector("a").GetAttribute("href");
foreach (var category in await GetProductCategoriesAsync(path))
Console.WriteLine($"-- {category.QuerySelector("a").GetAttribute("href")}");
public static async Task<IHtmlCollection<IElement>> GetProductsAsync()
var html = await client.GetStringAsync("Products");
var document = await html.ToDocument();
return document.QuerySelectorAll("section.cd-gallery li.mix");
public static async Task<IHtmlCollection<IElement>> GetProductCategoriesAsync(string path)
var html = await client.GetStringAsync(path);
var document = await html.ToDocument();
return document.QuerySelectorAll("div.pagelink li[id]");