parsing an image url from an html file

后端 未结 3 1542
我在风中等你
我在风中等你 2021-01-16 04:49

I want to search through a html file and then get the url to an image on that page. This url should then be saved as a string - thats all. The problem is I really don t know

3条回答
  •  借酒劲吻你
    2021-01-16 05:38

    Okay this did the job :) I am getting the image url now:

    public class jSoupEx {
    
        private static final String elements = null;
    
        public static void main(String args[]){
    
    
            try {
                Document doc = Jsoup.connect("http://***/index.php/Datei:***.jpg").get();
                Element image = doc.select("img").first();
                String url = image.absUrl("src");
                System.out.println(url);
    
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
    }
    

    }

提交回复
热议问题