I have an app that\'s basically a database of images stored on my local drive. Sometimes I need to find a higher resolution version or the web source of an image, and Google
This is easy to do if you're happy to install the requests module. The reverse image search workflow currently consists of a single POST request with a multipart body to an upload URL, the response to which is a redirect to the actual results page.
import requests
import webbrowser
filePath = '/mnt/Images/test.png'
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)
Of course, remember that Google may decide to change this workflow at any point!