I'm trying to scrape some data from aliexpress using c# and html-agility-pack.
Usually, the xpath of some element looks like this :
/html/body/div[7]/div[2]/div[4]/div/div/div[2]/div[1]/div[2]/div/div[1]/a
But when i try to copy the xpath of an element in aliexpress it looks like this :
//*[@id="node-gallery"]/div[4]/div/div/ul/li[1]/div[1]/div[1]/a
and then the list of nodes return null and the program can't make any progress.
var html = @"https://best.aliexpress.com/?lan=en";
HtmlWeb web = new HtmlWeb();
var htmlDoc = web.Load(html);
var nodes = htmlDoc.DocumentNode.SelectNodes("//*[@id]/div/div[2]/div/div[2]/dl//dd/div/div[2]/ul/li//a");
if (nodes.Count <= 0)
{
Console.WriteLine("nothing found");
}
else
{
foreach (HtmlNode n in nodes)
{
Console.WriteLine(n.Attributes);
}
}
Console.ReadKey();