Hi all,
I used urllib2.build_opener() to download an image from a corresponding url.But for a particular url i am getting error.When i checked that url i came to know that there is no image.How can i check whether there is image or not.This is my code
opener1 = urllib2.build_opener()
page1=opener1.open(orginal)
my_picture=page1.read()
The error i got is
File "suitcase.py", line 120, in <module>
get_suitcase()
File "suitcase.py", line 96, in get_suitcase
page1=opener1.open(orginal)
File "D:\Program Files\Python\lib\urllib2.py", line 395, in open
response = meth(req, response)
File "D:\Program Files\Python\lib\urllib2.py", line 508, in http_response
'http', request, response, code, msg, hdrs)
File "D:\Program Files\Python\lib\urllib2.py", line 433, in error
return self._call_chain(*args)
File "D:\Program Files\Python\lib\urllib2.py", line 367, in _call_chain
result = func(*args)
File "D:\Program Files\Python\lib\urllib2.py", line 516, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 404: Not Found
How to check image is there and proceed with saving that image
regards
arun