How to parse simple html code with jsoup? android

后端 未结 2 1493
臣服心动
臣服心动 2021-01-23 00:39

This is the part of my html code

                    

dr James – opiekun naukowy

相关标签:
2条回答
  • 2021-01-23 01:22

    This is the part of my html code

    <pre style="word-wrap: break-word; white-space: pre-wrap;">90</pre>
    

    I am new in jsoup, so I would be grateful if you write me a code, just for parsing the text to the android activity.

    0 讨论(0)
  • 2021-01-23 01:34

    There are various ways to extract data using jsoup. Check http://jsoup.org/cookbook/extracting-data/selector-syntax.

    In your case to get the text and image sources you could do like

    Document doc = Jsoup.connect(url).get();
    for(Element div : doc.select("div")){
        System.out.println(div.text());
        for(Element img : div.select("img")){
            System.out.println(img.attr("src"));
        }
    }
    
    0 讨论(0)
提交回复
热议问题