ユーザー名とパスワードを持っている Web サイトからすべての画像をダウンロードする必要があります。たとえば、ウェブサイトの URL は http://example.co.in/images/Photos/ABC123.jpg で、画像がたくさんあるので、すべての画像をダウンロードする必要があります。Java、C++、または任意のプログラミング言語で何ができますか? サンプルコードが役に立ちます。ありがとう
次のコードを使用して、Google Web サイトから画像を取得します
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();
}}
画像の名前がわからない場合、拡張子が .jpg (*.jpg) のすべての画像があり、フォルダーに 1.jpg、2.jpg などとして保存する必要があります。画像の数を取得する方法とhttp://www.google.co.in/images/で画像の名前にアクセスする方法