簡體   English   中英

如何使用jsoup提取圖像URL

[英]How to extract image urls using jsoup

我想從網站獲取內容,例如圖像的titlesrc屬性。 任何人都可以幫助我實現這一目標。

這是讀取所有圖像srctitle屬性的示例:

public class Test {

    public static void main(String[] args) {
        try {
            Document doc = Jsoup.connect("http://www.golem.de/").get();
            Elements imageElements = doc.getElementsByTag("img");
            for (Element element : imageElements) {
                System.out.println("src: "+element.attr("src"));
                System.out.println("title: "+element.attr("title"));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM