Last active
May 6, 2020 20:11
-
-
Save vainolo/9922ef7fb21fb340555759258c3846aa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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