Python 3.x 如何改进Python反向图像搜索以限制到特定域?
我正在使用Python 3.8。我有以下启动谷歌反向图像搜索的脚本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
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年开始的。当我今天测试它时,它起作用了。