<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.7.3</version>
</dependency>
public class JsoupDownImg {
public static void main(String[] args) throws IOException {
String url = "http://www.ososxt.com/platform/xuan?tag=searchCourseList&type=75";
Document document = Jsoup.parse(new URL(url), 10000);
Element content = document.getElementById("crrimList");
System.out.println(content);
Elements imgs = content.getElementsByTag("img");
System.out.println(imgs);
int id = 0;
for (Element img : imgs) {
String src = img.attr("src");
URL target = new URL(src);
URLConnection urlConnection = target.openConnection();
InputStream inputStream = urlConnection.getInputStream();
id++;
OutputStream outputStream = new FileOutputStream("C:\\Users\\Administrator\\Desktop\\常使用文件\\img\\jsoup\\"+id+".jpg");
int temp = 0;
while ((temp=inputStream.read())!=-1){
outputStream.write(temp);
}
System.out.println(id+".jpg下载完毕");
outputStream.close();
inputStream.close();
}
}
}