I am trying to fetch google trends page and the images that are shown are something in the code are actually like this
Since i need the real path to the image with its extension, is there any way to retrieve it?
Thank you.
I am trying to fetch google trends page and the images that are shown are something in the code are actually like this
Since i need the real path to the image with its extension, is there any way to retrieve it?
Thank you.
First off, this sounds like you're trying to screenscrape. Your life might be easier if you can review the API for google-trends and use that instead (but I don't know that api well enough to help you on that front; I did add the google-trend (in a to be peer reviewed edit) to your post to try to attract who do.)
Having said that, can you download the image and look at the content-type (assuming that image doesn't redirect to the underlying image in which case your problem should be solved.) You didn't specify what language you were using, so I'm going to assume you're using the right one :).
Example code (python, using requests library):
import requests
r = requests.get("http://gstatic.foo.com/blah/randomkeyboardtypingdetected/")
ctype = r.headers.get("content-type",None)
lookup = {"image/jpeg":"jpg","image/png":"png"} # add others as needed
if ctype and lookup.get(ctype,None):
print lookup.get(ctype)
else:
print "Error, server didn't specify.
It is a real path, image is retrieved dynamically so path is not like regular one with file-name, extension etc.
You can check content type
from response headers if you want to determine type of image.