문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top