I a m trying to pull links from a website, the HTML of what I want look like the below:
<div class="default-2-3">
<h4>
<a href="/en/news/esports/esports-editorial/na-lcs-week-8-tease-tsm">NA LCS Week 8 Tease: TSM</a>
</h4>
My test code looks like:
string mainURL = "http://na.leagueoflegends.com/en/news/";
HtmlAgilityPack.HtmlWeb web = new HtmlAgilityPack.HtmlWeb();
HtmlAgilityPack.HtmlDocument doc = web.Load(mainURL);
var findClass = doc.DocumentNode.Descendants("div")
.Where(d => d.Attributes.Contains("class") &&
d.Attributes["class"].Value.Contains("default-2-3"));
MessageBox.Show(findClass.ElementAt(1).ToString());
Currently the message box shows:
HtmlAgilityPack.htmlNode
I based my code off of this finding specific link from website, I am new to using HTMLAgilityPack beyond just copying the XPath.
For reference, the site I am trying to extract information is: http://na.leagueoflegends.com/en/news/