我正在使用 Python 3.8。我有以下用于启动 Google 反向图像搜索的脚本...
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
来限制对特定域的正常搜索。 .所以你可以在参数 q
中使用它您的 POST 请求:
domain = 'wikipedia.org'
multipart = {'encoded_image': (filePath, open(filePath, 'rb')), 'image_content': '',
'q': f'site:{domain}' }
关于python-3.x - 如何优化我的 Python 反向图像搜索以限制到特定域?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62786536/