I'm trying to get a third webPage content in my project with HtmlAgilityPack. The first two, works perfectly fine and i can get the content that i want. But each time i try with a third website (In a different class), a system.NullReference Exception is thrown and i don't understand why, the class that i'm looking for is on the website, i've tried to just get the body Element by a basic code but it seems that i can not have more than two websites in my project
private void extractNomsJoueurs(HtmlAgilityPack.HtmlDocument doc)
{
var links = doc.DocumentNode.SelectNodes("//*[contains(@class, 'bets ml')]");
var names = links.Elements("span");
foreach (var name in names)
{
listNames1Bet777.Add(name.InnerText);
}
for (int i = 0; i < listNames1Bet777.Count(); i++)
{
if (i % 2 == 0)
{
listNames2Bet777.Add(listNames1Bet777[i]);
}
}
foreach (string name in listNames1Bet777)
{
listNames1Bet777.Remove(name);
}
}
Exception thrown: 'System.NullReferenceException' in BotProper.exe
links was null.
PS: Apologies for my bad english.