Solution 1 :

Use load for only files. In this example, you ar loading an url,
So you should use web.LoahHtml
İf you do this. It will work

Solution 2 :

HtmlAgilityPack does not handle javascript, so you can use selenium to store the html source code via webDriver.

IWebDriver webDriver = new ChromeDriver();

webDriver.Url = "https://www.hltv.org/results";
var pageSource = webDriver.PageSource;

var doc = new HtmlDocument();
doc.LoadHtml(pageSource);

 var xPath = @"//*[@class='team team-won']";

 var node = doc.DocumentNode.SelectSingleNode(xPath);

 Console.WriteLine(node.InnerText);

Make sure that you have already downloaded and stored in same directory the webDriver.(i used chrome driver downloaded from here https://chromedriver.chromium.org/downloads)

Problem :

I’m trying to get data from this site: https://www.hltv.org/results, and it doesnt work. SelectNodes always returns null, I’ve tried using xpath, full xpath and so on and different things other than HtmlAgilityPack. Maybe its not the HtmlAgilityPack maybe the problem is in the tags.
Please take a look at the code and view also the tags to see if if i copied it right:

    HtmlWeb web = new HtmlWeb();
    var doc = web.Load("https://www.hltv.org/results");
    var teams = doc.DocumentNode.SelectNodes("//*[@class='team team-won']");

Please Help, Thanks!

Comments

Comment posted by SimplyBoost

thank you it worked ive tried to do it with htmlagilitypack and other stuff for days! thanks!!

By

Leave a Reply

Your email address will not be published. Required fields are marked *