1

Its my first qustion in this site and hope to stay longer :=) I have read a lot of article and examine many kind of example about taking specific datas from web site using Jsoup. Alread, I could manage to get some values but I couldn't succed my target which is to read alarm states from some web server so that I can collect them and send to technician. Unfortunatelly, I don't know the hierarchy. If anyone can tell me how to read the value headlined with red squre. I hope I could explain what ı need clearly. Thanks in advance

public static void main(String[] args) throws IOException {
     File htmlFile = new File("http://162.196.43.36");
        Document doc = Jsoup.parse(htmlFile, "UTF-8");

        // First <div> element has class ="related-container"
        Element div = doc.select("td.imgstatus").first();
        System.out.println(div);

1

samio
  • 11
  • 3

1 Answers1

0
public static void mainjdk7(String ... args){

    Connection connect = Jsoup.connect("http://www.yahoo.com");
    try {
        Document dom = connect.get();
        dom.getElementsByTag("section").forEach(new Consumer<Element>() {
            @Override
            public void accept(Element element) {
                Elements imgstatus = element.getElementsByClass("imgstatus");
                if(null != imgstatus){
                    //Do something
                }

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

public static void mainjdk8(String ... args){
    Connection connect = Jsoup.connect("http://www.yahoo.com");
    try {
        Document dom = connect.get();
        dom.getElementsByTag("section").forEach(element -> {
            Elements imgstatus = element.getElementsByClass("imgstatus");
            if(null != imgstatus){
                //Do something
            }
        });
    } catch (IOException e) {
        e.printStackTrace();
    }
}

hope this works for you.... Happy Coding :)

Ramkumar Pillai
  • 154
  • 2
  • 8