image - Bing 图像搜索 API 按格式过滤

标签 image azure bing

我正在使用此查询https://api.datamarket.azure.com/Bing/Search/v1/Image?Query=delhaize%20logo连接到 Bing 图像搜索 API 并查找所需的图像。这非常好用,但我喜欢 Bing 仅返回 jpg 和 png 图像。我在任何地方都找不到如何使用 Bing 过滤图像格式。

我找到了this有关图像过滤器的页面,但它没有在任何地方提到图像格式。

有什么想法吗?

最佳答案

不,没有方法可以按图像格式进行过滤。你可以这样做(php):

$word = 'monitor';
$extension = 'jpg';

$request = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&Query=%27'.urlencode($word).'%27&Adult=%27Strict%27&ImageFilters=%27Size%3AMedium%2BAspect%3AWide%2BColor%3AColor%2BStyle%3APhoto%27';
$process = curl_init($request);
curl_setopt($process, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($process, CURLOPT_USERPWD,  "$accountKey:$accountKey");
curl_setopt($process, CURLOPT_TIMEOUT, 30);
curl_setopt($process, CURLOPT_RETURNTRANSFER, TRUE);
$response = curl_exec($process);
$json = json_decode($response, true);

if(is_array($json['d']['results'])) {
    foreach($json['d']['results'] as $image) {
        if(pathinfo($image['MediaUrl'], PATHINFO_EXTENSION) == $extension) {
            # update values
            $urls[] = $image['MediaUrl'];
        }
    }
}

print_r($urls);

这将找到与“monitor”字符串匹配的图像,然后您只需在 php 中过滤它们即可。

关于image - Bing 图像搜索 API 按格式过滤,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31537676/

相关文章:

html - 灯箱的奇怪行为

wordpress - 在 Azure VMSS 上使用 Cloud Init 部署 WordPress 时收到 502 错误网关

Azure 应用程序未向 AAD 注册

git - 让 Git 在 Visual Studio 中忽略 WebDeploy 的 PublishProfile

javascript - Bing.com 如何创建放大的缩略图?

python - Raspberry pi 不会显示 pil 图像

php - 想像 |渐变贴图

java - 如何匹配BufferedImage和Mat的颜色模型?

php - 如何区分 Google Bot 访问和 Bing Bot 访问

bing-maps - Bing map 、VirtualEarth、MapPoint——它们之间有何关联?