I'm trying to reverse image search a url from an android app. The base url I'm using is:
https://images.google.com/searchbyimage?image_url=
This works for most urls, however certain ones don't working from the app, for example with the url from a reddit post:
https://i.reddituploads.com/bb7b0423593e413f88126a3a970dfb1a?fit=max&h=1536&w=1536&s=a057607161cdbab59d30ee2c6f0d88f0
which becomes
https://images.google.com/searchbyimage?image_url=https://i.reddituploads.com/bb7b0423593e413f88126a3a970dfb1a?fit=max&h=1536&w=1536&s=a057607161cdbab59d30ee2c6f0d88f0
But that says "The URL doesn't refer to an image, or the image not publicly accessible." However if I go to images.google.com and paste https://i.reddituploads.com/bb7b0423593e413f88126a3a970dfb1a?fit=max&h=1536&w=1536&s=a057607161cdbab59d30ee2c6f0d88f0
manually it works perfectly fine. Any ideas why it would be having an issue with some urls and not others?
You need to encode the URL first to something like:
https://images.google.com/searchbyimage?image_url=https%3A//i.reddituploads.com/bb7b0423593e413f88126a3a970dfb1a%3Ffit%3Dmax%26h%3D1536%26w%3D1536%26s%3Da057607161cdbab59d30ee2c6f0d88f0
I am familiar with java, but python has a function to encode the URL to the desired form:
urllib.parse.quote