I'm trying to do a web scraper for the league of legend's page. I'm trying to first get a list of all champions from here http://gameinfo.euw.leagueoflegends.com/en/game-info/champions/ .
However, I can't figure out why is my loop not working.
Here is my code:
Document doc = Jsoup.connect("http://gameinfo.euw.leagueoflegends.com/en/game-info/champions").get();
Elements span = doc.select("div#champion-grid-container > div.content-border > div#champion-grid-content > div.rg-box-container rg-display-Riot.champions.GridView > ul > li");
if(span != null){
System.out.println("The class grid exist!!");
Elements lista = span.select("li#champion-grid-aatrox");
if(lista != null){
System.out.println("li#champion-grid-aatrox Exist!!");
}else{
System.out.println("Nop :(");
}
Elements maidep = lista.select("div.champ-name");
if(maidep != null){
System.out.println("div.champ-name Exist!!");
}else{
System.out.println("Nop :(");
}
Elements maidep2 = maidep.select("a[href]");
if(maidep2 != null){
System.out.println("a Exist!!");
}else{
System.out.println("Nop :(");
}
for(Element nuj : maidep2)
System.out.println("Content is " + nuj.text());
}
else {
System.out.println("Class Grid Nop:(");
}
I know it's a bad practice to select divs like that, at first I tried to go all the way in one select to that particular element, but it was not returning anything so I wanted to go through each div/parent until I got there and see where it gets lost. The output is this:
The class grid exist!!
li#champion-grid-aatrox Exist!!
div.champ-name Exist!!
a Exist!!
So the "Content is" message is not even displayed.