私はGoogleで検索しようとしています-画像はいくつか異なり、JavaGoogleAPIを使用してすべてのクエリの最初の結果を保存します。
私はなんとかGoogleで検索し、検索結果を含むjsonオブジェクトを取得しました。オブジェクトには、画像アドレスではなく、画像を含むWebサイトが含まれています
コード:
URL url = new URL("https://ajax.googleapis.com/ajax/services/search/images?" +
"v=1.0&q="+properties.getProperty(Integer.toString(i))+"&userip=IP");
URLConnection connection = url.openConnection();
connection.addRequestProperty("Referer", "images.google.com");
String line;
StringBuilder builder = new StringBuilder();
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
while((line = reader.readLine()) != null) {
builder.append(line);
}
JSONObject json = new JSONObject(builder.toString())
画像リンクがあれば画像を保存する方法も知っています。
私の問題は、Webアドレスではなく、最初の(または2番目の)画像の正しいアドレスを取得する方法です(例www.yadayadayada.com/image.png)
10倍