Diving into span data - parsing HTML website

Multi tool use
Multi tool use


Diving into span data - parsing HTML website



I've tried to get all restaurant names in the website https://www.yemeksepeti.com/en/istanbul/zeytinburnu-merkezefendi-mah-cevizlibag
using the HtmlAgilityPack:


Uri url = new Uri("https://www.yemeksepeti.com/en/istanbul/zeytinburnu-merkezefendi-mah-cevizlibag");
WebClient client = new WebClient();
string downloadString = client.DownloadString(url);

HtmlAgilityPack.HtmlDocument document = new HtmlAgilityPack.HtmlDocument();
document.LoadHtml(downloadString);

HtmlNodeCollection nodes = document.DocumentNode.SelectNodes("//a[@class='restaurantName withTooltip']");

foreach(var node in nodes) {
listBox1.Items.Add(node.InnerText);
}



This one works nice!



But on the other hand, what I really want to do is to dive deeper and get MainCuisineName below:


MainCuisineName


<a class="restaurantName withTooltip" href="/en/meshur-merkez-kofte-zeytinburnu-merkezefendi-mah-istanbul" target="_parent" data-hasqtip="1">
<span data-tooltip="{&quot;MainCuisineName&quot;:&quot;Meatball&quot;&quot;cc_genel.gif}">Meşhur Merkez Köfte, Zeytinburnu (Merkezefendi Mah.)</span>
</a>



How can i get MainCuisineName,which is "Meatball", from
same URL? I tried this:


MainCuisineName


HtmlNodeCollection nameNodes = doc.DocumentNode.SelectNodes("//*[@class='restaurantName withTooltip']/span='MainCuisineLabelName'");

foreach(var node in nameNodes) {
listBox1.Items.Add(node.InnerText);
}



But it is apperantly not working.



Any suggestions?









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Vcm7fM
1VMbsWLbrpQhk9AYi,nff3Cw3TbY,9udmgO9NiyJxmO5l3Hfx,YOTRUMF0gWGg7 azOaZ9MQkVbN,pgYKq,7bXOg

Popular posts from this blog

PHP contact form sending but not receiving emails

Do graphics cards have individual ID by which single devices can be distinguished?

Create weekly swift ios local notifications