【问题标题】:Is It possible to get 1000 images using bing search API是否可以使用必应搜索 API 获取 1000 张图像
【发布时间】:2014-03-17 07:44:18
【问题描述】:

我正在使用 bing 搜索图像 API

我只收到了来自 bing 的 10 张图片,但我需要 1000 张图片。是否可以检索 1000 张图像?

请检查我的代码:

<?php
if (isset($_POST['submit'])) {
 $Key = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; // this is my api key
 $request ='http://api.bing.net/json.aspx?Appid=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA&sources=image&query=' . urlencode( $_POST["searchText"]);
 $response = file_get_contents($request);
 $jsonobj = json_decode($response);
 echo('<ul ID="resultList">');
 foreach($jsonobj->SearchResponse->Image->Results as $value){
  echo('<li class="resultlistitem"><a href="' . $value->Url . '">');
  echo('<img src="' . $value->Thumbnail->Url. '" width="150" height="150"></li>'); 
 }
 echo("</ul>");
}
?>

【问题讨论】:

  • 查看文档以了解寻呼机功能。可能有。

标签: php bing


【解决方案1】:

根据this document,您可以使用countoffset参数来做到这一点:

http://api.bing.net/xml.aspx?Appid=&lt;AppID&gt;&amp;query=sushi&amp;sources=web&amp;web.count=40&amp;web.offset=41

【讨论】:

  • 它工作正常。但是在 bing 中,根据我的搜索关键字提供的图片数量有限,但我需要 1000 张图片,这可能吗??
  • 您可以发送多个请求并合并结果。
  • 如果您使用基于 Web 的搜索,则意味着它可以在您的代码之上运行。如果使用基于图像的搜索,则仅显示来自 bing 的最小结果量。 api.bing.net/…
  • 我认为你误会了。例如,如果 Bing API 限制为 100 个图像结果/请求,您可以通过调用具有不同 countoffset 参数的 10 个请求来获得 1000 个结果:count=100&amp;offset=1count=100&amp;offset=101count=100&amp;offset=201、...跨度>
  • 嗨@TrungDQ 我试过了,但它可以重复显示相同数量的图像。请检查我的编码api.bing.net/… 更改偏移值它将显示相同的图像,因为它提供最少数量的图像例如寿司总数图像是 171。当达到它重复的总数时。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-09-26
  • 2013-02-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-10-28
  • 2011-06-19
相关资源
最近更新 更多