Need to parse image src from HTML page then display it

后端 未结 3 1397
一整个雨季
一整个雨季 2021-01-15 21:05

I\'m currently trying to develop an app whereby it visits the following site (Http://lulpix.com) and parses the HTML and gets the img src from the following section

3条回答
  •  爱一瞬间的悲伤
    2021-01-15 21:57

    I recently used JSoup to parse invalid HTML, it works well! Do something like...

        Document doc = Jsoup.parse(str);
        Element img = doc.body().select("div[class=pic rounded-8] img").first();
        String src = img.attr("src");
    

    Play with the "selector string" to get it right, but I think the above will work. It first selects the outer div based on the value of its class attribute, and then any descendent img element.

提交回复
热议问题