mardi 4 octobre 2016

parse nodeList Value using Jsoup

http://ift.tt/2duy586

In this Website, I tried to parse the value of the table for the currency.

The below value in the table is the value I want to extract.

In developer tool, I can see the value only in 'Elements' window, not in 'source' window. I guess the data is called using ajax? How can I extract the data using Jsoup?

Here's the code I was trying to parse the code. And it failed...

try {
          doc = Jsoup.connect("http://ift.tt/2duy586").get();
       } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
       }
       //Elements exchangeRateElement = doc.select(".brb0 td:nth-child(3)").eq(1);           
       Element exchangeRateElement = doc.getElementsByClass("brb0").get(10);

       String cur=null;

       for (Node node : doc.childNodes()) {
        System.out.println("node : "+node);
         if (node instanceof TextNode) {
            cur = ((TextNode) node).getWholeText();
            cur = ((TextNode) node).text();
             break;
         }
     }

Thank you for your help!




Aucun commentaire:

Enregistrer un commentaire