Skip to content

Instantly share code, notes, and snippets.

@vainolo

vainolo/Method1.cs

Last active May 6, 2020
Embed
What would you like to do?
public static void Scrape()
{
var scraper = new HtmlWeb();
var page = scraper.Load("https://vainolo.z14.web.core.windows.net/WebScraping.html");
var techniquesTitle = page.GetElementbyId("Techniques");
var currNode = techniquesTitle.ParentNode.NextSibling;
while(currNode.Name != "h2")
{
if(currNode.GetClasses().Contains("mw-headline"))
{
var headline = currNode.InnerText;
Console.WriteLine(headline);
}
if(currNode.HasChildNodes)
{
currNode = currNode.FirstChild;
}
else if(currNode == currNode.ParentNode.LastChild)
{
while(currNode.ParentNode.NextSibling == null)
{
currNode = currNode.ParentNode;
}
currNode = currNode.ParentNode.NextSibling;
}
else
{
currNode = currNode.NextSibling;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.