zoukankan      html  css  js  c++  java
  • 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 count函数
    kubenetes服务发现
    k8s网络
    k8s创建pod流程
    openstack创建虚拟流程、各组件介绍
    生产者消费者问题
    Date类和Calendar类
    Timer定时器
    Java中的克隆
    注解
  • 原文地址:https://www.cnblogs.com/codworm/p/12444804.html
Copyright © 2011-2022 走看看