Bing Visual Search帮助 [英] Bing Visual Search Help

查看:73
本文介绍了Bing Visual Search帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 我们如何使用python API限制bing视觉搜索以从自定义/特定网站获取结果?


使用下面的python API我能够从中提取结果下面的多个网站是我正在使用的代码,但我想从一个特定的网站获得类似的图像。如何限制我的搜索?


参考:" https://docs.microsoft.com/en -us / azure / cognitive-services / bing-visual-search / quickstarts / python"


代码:


导入请求,json


BASE_URI ='https:// api .cognitive.microsoft.com / bing / v7.0 / images / visualsearch'
$
SUBSCRIPTION_KEY ='Key'

imagePath ='Image'


HEADERS = {'Ocp-Apim-Subscription-Key':" Key"}'


file = {'image':('myfile',open(imagePath, 'rb'))}


def print_json(obj):

    """打印对象为json"""

    print(json.dumps(obj,sort_keys = True,indent = 2,separators =(',',':')))


尝试:


    response = requests.post(BASE_URI,headers = HEADERS,files = file)

    response.raise_for_status()

    print_json(response.json())



,例外情况除外:

   提高ex


谢谢,


Gautham

解决方案

您好,


感谢您的反馈。您能否分享一些有关如何限制搜索的详细信息?比如,你想过滤你的结果/摆脱重复?通过这种方式,您可以通过自定义python脚本来实现。



问候,


浴桶


 How do we restrict the bing visual search using python API to get results from custom/specific website?

Using below python API I was able to extract results from multiple websites below is the code that I am using, but I want to get the similar images from one specific website. How can I restrict my search?

Reference : "https://docs.microsoft.com/en-us/azure/cognitive-services/bing-visual-search/quickstarts/python"

Code:

import requests, json

BASE_URI = 'https://api.cognitive.microsoft.com/bing/v7.0/images/visualsearch'
SUBSCRIPTION_KEY = 'Key'
imagePath = 'Image'

HEADERS = {'Ocp-Apim-Subscription-Key': "Key"}'

file = {'image' : ('myfile', open(imagePath, 'rb'))}

def print_json(obj):
    """Print the object as json"""
    print(json.dumps(obj, sort_keys=True, indent=2, separators=(',', ': ')))

try:

    response = requests.post(BASE_URI, headers=HEADERS, files=file)
    response.raise_for_status()
    print_json(response.json())

except Exception as ex:
    raise ex

Thanks,

Gautham

解决方案

Hi,

Thanks for your feedback. Could you please share more details about how you want to restrict your searching? Like, you want to filter your result/ get rid of duplicate? In this way, you can do it just by custom your python script.

Regards,

Yutong


这篇关于Bing Visual Search帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆