Domanda

I try to use Jsoup to parse an HTML page, but the only thing that I have, is "................". I want to get the text in the option tag. At this URL : http://timetables.dkit.ie/room.php, I want to get the text in the second table.

This is my code :

Document doc;
String elementToFind;

try {

doc = Jsoup.connect("http://timetables.dkit.ie/room.php").get();
    Elements links = doc.select("select");                            

    links.stream().forEach((link) -> {

        if(link.attr("name").equals("identifier")){

            for(Element element : link.children()){

                System.out.println("Option : " + element.text());

    }
        }

    });

} 

catch (IOException e) {
    e.printStackTrace();
}

And the result :

Option : ...................................................................................... Option : ...................................................................................... Option : ...................................................................................... Option : ...................................................................................... Option : ...................................................................................... Option : ...................................................................................... Option : ...................................................................................... Option : ...................................................................................... Option : ...................................................................................... Option : ...................................................................................... Option : ...................................................................................... Option : ......................................................................................

Furthermore, I expect something like 200 options, and there are less than 20 options.

Thanks for helping me.

È stato utile?

Soluzione

The problem here is the multi select is populated via javascript. The initial value is ............. and the javascript dynamically populates the value. I don't think you would e able to get a JavaScript variable value from a Java program.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top