0

There was a response to a question on image reverse search that had this code. I can get it to work however when I look at the response it isn't helpful. I've tried response.text/json but it just shows the returned url. It produces the url regardless of if the image exists on google so isn't too meaningful.

How do I extract meaningful information from the response?

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)

Question this response was provided: Google reverse image search using POST request

  • this method doesn't use API but simply run the same code as browser - and you may have to use `requests` to read HTML from url `fetchUrl` and parse data using `beautifulsoup`. OR you should read documentation for Google API to see if it has option to get it as JSON. But this code is NOT Google API. – furas Jul 18 '22 at 12:03
  • @Weetman is your issue was resolved? – Attaullah Apr 25 '23 at 16:27

0 Answers0