I want to scrape a href from a youtubelplaylist-link using HTML agility pack. This code works, but the problem is that it's a table, and I don't know how to scrape each href separately.
var html = new HtmlDocument();
html.LoadHtml(new WebClient().DownloadString("https://www.youtube.com/playlist?list=PLirAqAtl_h2r5g8xGajEwdXd3x1sZh8hC"));
var root = html.DocumentNode;
var p = root.Descendants()
.Where(n => n.GetAttributeValue("class", "").Equals("pl-video-title"))
.FirstOrDefault()
.Descendants("a").Select(node => node.GetAttributeValue("href", ""))
.FirstOrDefault();
var points = ("https://youtube.com/embed/" + (Regex.Replace(p, "list=PLirAqAtl_h2r5g8xGajEwdXd3x1sZh8hC&index=1", "").Trim()));
This code works, but the problem is that it's a table and with this code I only recieve the first href, and I don't know how to scrape each href separately in the table (about 10 of them). This is the "Selector/ID/class" I wan't to scrape from:
#pl-load-more-destination > tr:nth-child(1) > td.pl-video-title
When I put this in instead of "pl-video-title" I get error.
I've been looking at XPath but I can't get it to work..