0

Google 画像から画像を要求するプログラムを作成しています。

配列に変換する JSON オブジェクトを取得します。しかし、何らかの理由で、制限のように聞こえる画像は常に 4 つしかありません。そしてそれを無効にしたい...

JSONArray results = json.getJSONObject("responseData").getJSONArray("results");
for(int j = 0; j < results.length(); j++) {
    String strurl = results.getJSONObject(j).getString("unescapedUrl");
    BufferedImage image = null;
    try {

        URL url = new URI(strurl).toURL();
        System.out.println("URL content type:"+url.openConnection().getContentType());
        URLConnection connection = url.openConnection();
        image = ImageIO.read(connection.getInputStream());
        } catch(MalformedURLException e) {
        e.printStackTrace();
        } catch(IOException e ) {
        e.printStackTrace();
        continue;
        } catch (URISyntaxException e) {
        e.printStackTrace();
    }
    // I display the image.
}

そして、results検索キーワードが何であれ、JSONArray は常に 3 です (私はそれを印刷しました)。

必要な結果の量を定義する方法はありますか?

私は絶望的です...どんな種類の答えでも、大穴でも感謝します.

4

1 に答える 1

0

ページが 4 つの画像のみを返すようです。だから私は追加しましstart=numberた。したがって、複数のリクエストを送信します。

于 2014-05-21T08:36:37.690 に答える