小编pra*_*shr的帖子

从网站获取图像

我需要从我有用户名和密码的网站下载所有图像.说,网站网址是 http://example.co.in/images/Photos/ABC123.jpg 这样有很多图片,我的要求是下载所有图片.可以用Java,C++或任何编程语言做什么?示例代码会很有帮助.谢谢

使用以下代码从Google网站获取图片

import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.net.URL;

class Test {
public static void main(String args[]) throws Exception {
    System.out.println("Hello World");

    URL url = new URL("http://www.google.co.in/images/google_favicon_128.png");
    InputStream in = new BufferedInputStream(url.openStream());
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    byte[] buf = new byte[1024];
    int n = 0;
    while (-1 != (n = in.read(buf))) {
        out.write(buf, 0, n);
    }
    out.close();
    in.close();
    byte[] response = out.toByteArray();

    FileOutputStream fos = new FileOutputStream("C://ABC//google1.jpg");
    fos.write(response);
    fos.close();

}}
Run Code Online (Sandbox Code Playgroud)

现在我需要帮助,我不知道图像的名称说所有带扩展名为.jpg(*.jpg)的图像,它应该存储在我的文件夹中,如1.jpg,2.jpg等.那么如何在http://www.google.co.in/images/中获取图像数量以及如何访问其名称

web-crawler

2
推荐指数
1
解决办法
2万
查看次数

标签 统计

web-crawler ×1