Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/315.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 谷歌图像请求只返回3张图像_Java_Json_Google Image Search - Fatal编程技术网

Java 谷歌图像请求只返回3张图像

Java 谷歌图像请求只返回3张图像,java,json,google-image-search,Java,Json,Google Image Search,我正在写一个程序,从谷歌图片请求图像 我得到一个JSON对象,并将其转换为数组。但由于某些原因,它总是只有4张图片,这听起来像是一个限制。我想禁用它 JSONArray results = json.getJSONObject("responseData").getJSONArray("results"); for(int j = 0; j < results.length(); j++) { String strurl = results.getJSONObject(j)

我正在写一个程序,从谷歌图片请求图像

我得到一个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.
}
不管搜索关键字是什么,JSONArray
结果总是3(我打印出来了)

有没有办法定义我想要的结果数量


我绝望了。。。对于任何类型的回答,即使是一个长镜头,我都会非常感激。

页面似乎只返回4幅图像。所以我添加了
start=number
。因此,我发送多个请求