1

I'm trying to get number of players from this website to string but it's not working. Here is my code:

public class Main {
    public static void main(String[] args) throws IOException {

        String url = "https://servers.fivem.net/servers/detail/4ljez8";
        Document document = Jsoup.connect(url).get();

        String players = document.select("div.players-count").first.text();

        System.out.print(players);
    }
}
HoRn
  • 1,458
  • 5
  • 20
  • 25
Raptor
  • 11
  • 1
  • Which Jsoup version are you using? Also, make sure to provide the right path in select(). – Tcheutchoua Steve Apr 01 '21 at 20:10
  • I'm using jsoup 1.13.1 and i thing i provided the right path in select. – Raptor Apr 01 '21 at 20:25
  • It appears the number of players is dynamically generated and for some reasons, Jsoup can't access that data. For example is you "View Page Source", you won't see the number of players and it's corresponding tag. My guess is by the time Jsoup tries to read the number of players, that data isn't yet available on the DOM. – Tcheutchoua Steve Apr 01 '21 at 23:09
  • Okey i understand thank you for your time. – Raptor Apr 02 '21 at 10:29

0 Answers0