搜寻Bing图像搜索仅返回12个结果

时间:2018-10-18 06:49:56

标签: java web-scraping jsoup bing

我正在使用出色的Jsoup库从Bing的图片搜索中抓取图片网址。该代码运行良好,但我只得到12个结果。如何获得更多结果?我的代码:

    String urlHead = "https://www.bing.com/images/search?q=";
    String searchTerm = strings[0];
    String urlTail = "&scope=images";


    Document document;
    try {
        document = Jsoup.connect(urlHead+searchTerm+urlTail)
                .userAgent("User-agent: Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/3B48b Safari/419.3")
                .referrer("http://www.google.com")
                .get();

    } catch (IOException e) {
        e.printStackTrace();
        return null;
    }
    Elements containers = document.getElementsByClass("iusc");

    ArrayList<String> jsonStrings = new ArrayList<>();
    for (Element element: containers){
        jsonStrings.add(element.attr("m"));
    }
    String urls[] = new String[jsonStrings.size()];
    int i = 0;
    for (String s: jsonStrings) {
        try {
            JSONObject o = new JSONObject(s);
            urls[i] = o.getString("murl");
            i++;
        } catch (JSONException e){
            e.printStackTrace();
        }
    }
    return urls;

我尝试将urlTail更改为: &t=ffab&atb=v110-4&iax=images&ia=images&scope=images&top=50&FORM=HDRSC2,但仍然只返回12个结果...

0 个答案:

没有答案