4

I'm using Python 3.8. I have the following script for launching a Google reverse image search ...

    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)

Does anyone how, if possible, I can refine the search to a specific domain?

Dave
  • 15,639
  • 133
  • 442
  • 830

1 Answers1

4

You can restrict normal searches to a particular domain by adding site:domain.com. So you can use that in a parameter q of your POST request:

domain = 'wikipedia.org'
multipart = {'encoded_image': (filePath, open(filePath, 'rb')), 'image_content': '', 
    'q': f'site:{domain}' }
jdaz
  • 5,964
  • 2
  • 22
  • 34