下载抓取-收费漫画-父与子

package com.chinada.dms.test.ysp;

import java.io.DataInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;

public class TestPicFZ {

    public static void main(String[] args) throws IOException {
        for(int a=10;a<99;a++){
            String imageUrl="";
            String aa=a+"";
/*            if(aa.length()>=2){
              //  String str="http://img7x5.ddimg.cn/imgother10/72/3/1900717605_figure_0013_0001_epub.jpg";
                  imageUrl = "http://img7x5.ddimg.cn/imgother10/72/3/1900717605_figure_00"+a+"_0001_epub.jpg";
            }*/
            imageUrl = "http://img7x5.ddimg.cn/imgother10/72/3/1900717605_figure_00"+a+"_0001_epub.jpg";
/*            else{
                imageUrl = "http://fastio.xcmh.cc/l/%E8%80%81%E5%A4%AB%E5%AD%90%E6%B0%B4%E6%B5%92%E4%BC%A0/%E7%AC%AC1%E5%9B%9E/0"+a+".png";
            }*/
            URL url = new URL(imageUrl);
            DataInputStream dis = new DataInputStream(url.openStream());
            String newImageName="D://image/"+a+".png";
            FileOutputStream fos = new FileOutputStream(new File(newImageName));
            byte[] buffer = new byte[1024];
            int length;
            while((length = dis.read(buffer))>0){
                fos.write(buffer,0,length);
            }
            dis.close();
            fos.close();
        }
        System.out.println("漫画数据抓取完毕!");
    }
}

你可能感兴趣的:(19webapp,22爬虫)