Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.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
Python 3.x 如何改进Python反向图像搜索以限制到特定域?_Python 3.x_Django_Image_Google Image Search - Fatal编程技术网

Python 3.x 如何改进Python反向图像搜索以限制到特定域?

Python 3.x 如何改进Python反向图像搜索以限制到特定域?,python-3.x,django,image,google-image-search,Python 3.x,Django,Image,Google Image Search,我正在使用Python 3.8。我有以下启动谷歌反向图像搜索的脚本 filePath = '/tmp/cat_and_dog.webp' searchUrl = 'http://www.google.hr/searchbyimage/upload' multipart = {'encoded_image': (filePath, open(filePath, 'rb')), 'image_content': '', } response = requests.po

我正在使用Python 3.8。我有以下启动谷歌反向图像搜索的脚本

    filePath = '/tmp/cat_and_dog.webp'
    searchUrl = 'http://www.google.hr/searchbyimage/upload'
    multipart = {'encoded_image': (filePath, open(filePath, 'rb')), 'image_content': '', }
    response = requests.post(searchUrl, files=multipart, allow_redirects=False)
    fetchUrl = response.headers['Location']
    webbrowser.open(fetchUrl)

有人知道如果可能,我如何将搜索细化到特定域吗?

您可以通过添加
site:domain.com
将正常搜索限制到特定域。因此,您可以在POST请求的参数
q
中使用该参数:

domain = 'wikipedia.org'
multipart = {'encoded_image': (filePath, open(filePath, 'rb')), 'image_content': '', 
    'q': f'site:{domain}' }

-类似的问题我试过
网站:
,但谷歌似乎忽略了答案是从2013年开始的。当我今天测试它时,它起作用了。