CSU-Max的gravatar头像
CSU-Max 2013-11-16 14:29:11

jsoup简单的图片抓取demo

昨天看到同学在一张张右键图片,感觉好麻烦,今天上午就查了一下资料,弄了个图片抓取器。

用到jsoup和 io包,我放在压缩文件里了。

新手刚刚弄,可能会有考虑不好的地方,欢迎大家多多指教。

 

jsoup简单的图片抓取demo

主要代码:

//遍历保存
Iterator<String> i = imgSrcSet.iterator();
			while(i.hasNext()){
				
				String imgSrc = (String)i.next();
				String imgName = FilenameUtils.getName(imgSrc);
				
				if (imgName.indexOf(".") != -1) {
					if (imgName.indexOf("?") > -1) {
						imgName = imgName.substring(0, imgName.indexOf("?"));
					}
					
					Util util = new Util();
					String saveImagePath = filePath+"/"+imgName;
					System.out.println("图片抓取开始:");
					util.download(imgSrc,saveImagePath);
					System.out.println("图片抓取结束:"+imgSrc+" 保存路径:"+saveImagePath);
					
				}

jsoup简单的图片抓取demo


打赏

文件名:ImageSpider.rar,文件大小:404.771K 下载
  • /
      • /ImageSpider
        • /ImageSpider/.classpath
        • /ImageSpider/.project
          • /ImageSpider/.settings
            • /ImageSpider/.settings/org.eclipse.jdt.core.prefs
          • /ImageSpider/bin
              • /ImageSpider/bin/com
                  • /ImageSpider/bin/com/csu
                      • /ImageSpider/bin/com/csu/test
                        • /ImageSpider/bin/com/csu/test/Main.class
                        • /ImageSpider/bin/com/csu/test/Util.class
          • /ImageSpider/架包
            • /ImageSpider/架包/commons-io-2.0.1.jar
            • /ImageSpider/架包/jsoup-1.7.2.jar
最代码最近下载分享源代码列表最近下载
zhangguobin  LV14 2019年9月10日
1662530129  LV12 2019年8月12日
yihang  LV7 2019年2月3日
dagf113225  LV68 2019年1月9日
756398953  LV12 2018年11月15日
冬瓜Summit  LV10 2018年6月11日
360763120  LV11 2018年4月27日
lindawhn  LV6 2018年4月12日
xl921005  LV1 2017年6月16日
yly123  LV17 2017年3月29日
最代码最近浏览分享源代码列表最近浏览
好的好的  LV8 2022年7月7日
qiaofu22  LV4 2022年6月3日
mySong  LV11 2022年3月3日
心印语  LV9 2022年3月3日
tdcq123  LV14 2022年1月18日
微笑刺客  LV15 2021年12月30日
Yangwanyun  LV4 2021年7月29日
wwwwwhx  LV10 2020年9月10日
lzxzuidaima  LV5 2020年5月7日
IraqiHa  LV6 2020年5月1日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友