Python Google 图片反向搜索命令行
生活随笔
收集整理的這篇文章主要介紹了
Python Google 图片反向搜索命令行
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
安裝依賴
pip install --upgrade -i https://pypi.tuna.tsinghua.edu.cn/simple requests webbrowser
使用說明
python Google_image_reverse_search.py 圖片路徑
代碼
#!/usr/bin/env python
# WARNING: I DON'T KNOW PYTHON AT ALL, THIS MAY BE GRUESOME AND IDIOTIC
import sys
filePath = sys.argv[-1]
print("opening: ", filePath)
import requests
searchUrl = 'http://www.google.com/searchbyimage/upload'
multipart = { 'encoded_image': (filePath, open(filePath, 'rb')), 'image_content': ''}
response = requests.post(searchUrl, files=multipart, allow_redirects=False)
fetchUrl = response.headers['Location']
print("found: ", fetchUrl)
def open_in_browser(url):
print("opening on browser...")
import webbrowser
webbrowser.open(url, new=2)
open_in_browser(fetchUrl)
exit(0)
總結
以上是生活随笔為你收集整理的Python Google 图片反向搜索命令行的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: shor怎么在java中使用
- 下一篇: html在状态栏中显示时间,html网页