user3456608
user3456608

Reputation: 21

How to return values from option tag

I am trying to return some information from flightradar24.com using jsoup.
The information I need is displayed in a drop-down box.

Here is my code:

public static void main(String[] args) {

    try {
    Document doc = Jsoup.connect("http://www.flightradar24.com/").get();
    Elements radarCode = doc.getElementsByTag("option");

    for(int i=0; i<radarCode.size(); i++) {
        System.out.println(radarCode.get(i).text() + "\n");
    }

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

I am trying to return all radar information that is displayed. If you go onto the website and click on filter over to the left hand side, a box will display. Find the radio button that says "Radar" and then it should show a drop down box. This drop down box is the one I am try to get the information from.

Upvotes: 1

Views: 343

Answers (1)

Andrew Phillips
Andrew Phillips

Reputation: 987

I think Pshemo's comment is correct. JSoup is great for static site, but the minute there is a need to get data generated from javascript, you need to upgrade to another solution. There are many good ones, pulling in a headless browser like HTMLUnit or PhantomJS, or Selenium (which can tie into a headless or standard browser like Firefox). Depending on your project, I'd start with HTMLUnit or Selenium with HTMLUnit.

Upvotes: 1

Related Questions