java - Problem with crawling images?
天蓬老师
天蓬老师 2017-06-23 09:12:30
0
1
710

Just modified POM, you can download the source code again

This is the project address of the crawler I wrote
The project does not report an error, but the problem is that after downloading the image to the local area, the image is often incomplete, as follows:

##This is the core code for downloading pictures, as follows:

@Override
    public void run() {
        Response res = null;
        try {
            res = Jsoup.connect(src).ignoreContentType(true).timeout(30000).execute();
            byte[] bytes = res.bodyAsBytes();
            File file = new File(path + name);
            if (!file.exists()) {
                RandomAccessFile raf = new RandomAccessFile(file, "rw");
                raf.write(bytes);
                raf.close();
            }
        } catch (IOException e1) {
            e1.printStackTrace();
        }
    }

After data query, I feel that it is a problem with the range request

Range or a problem that I did not find? I hope you can take a look at it, thank you

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!