python-3.x - 如何优化我的 Python 反向图像搜索以限制到特定域?
问题描述
我正在使用 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 - 将 OLE DB SQL 连接字符串转换为数据框?
- azure-ad-b2c - 通过 Keep me signed in (KMSI) 作为 Azure B2C 中的输出声明
- c++ - 如何读取文本文件的第 2 行、第 3 行和第 4 行。C++
- python - 如何将 csv 的嵌套 dict 格式的“_source”列展平为数据框
- r - 如何根据同一列中日期之间的间隔进行重复数据删除
- tensorflow - 在 Google Colab 中使用多个 GPU 在 Tensorflow 中进行分布式训练
- typescript - 从 RxJS Observable 过滤 undefined
- javascript - 如何检查两组单选按钮是否匹配
- java - 基于其他方法返回类型的单元测试布尔方法
- python - 多处理器数值加法器