I would like to handle the error:
"httperror_seek_wrapper: HTTP Error 404: Not Found"
And instead just return an empty string. But I'm not sure what the except statement should be. I apologize if there is a duplicate post, but none of the posts that popped up seemed to deal with excepting this error, but rather figuring out what had gone wrong at a deeper level. I, however, just want to pass along and return an empty string.
Basically, I'm looking for what should go in the blank:
try:
....
except _____:
....
Thanks!
_____
Here is the code where the error gets thrown.
---------------------------------------------------------------------------
httperror_seek_wrapper Traceback (most recent call last)
<ipython-input-181-e2b68bf19ff9> in <module>()
5
6 for i in range(len(first)):
----> 7 student_html = get_stud_html(first[i],last[i],'Sophomore')
8 # print type(student_html)
9 # print parse_hfb_page(student_html)
<ipython-input-177-9b1d4294820d> in get_stud_html(first, last, year)
60 #ideally will want to use a regex to do this in case there's more than one link on the page
61 stud_url = 'http://facebook.college.harvard.edu/'+links_lst[12]
---> 62 stud_html = br.open(stud_url)
63 return stud_html.get_data()
64
//anaconda/python.app/Contents/lib/python2.7/site-packages/mechanize-0.2.5-py2.7.egg/mechanize/_mechanize.pyc in open(self, url, data, timeout)
201 def open(self, url, data=None,
202 timeout=_sockettimeout._GLOBAL_DEFAULT_TIMEOUT):
--> 203 return self._mech_open(url, data, timeout=timeout)
204
205 def _mech_open(self, url, data=None, update_history=True, visit=None,
//anaconda/python.app/Contents/lib/python2.7/site-packages/mechanize-0.2.5-py2.7.egg/mechanize/_mechanize.pyc in _mech_open(self, url, data, update_history, visit, timeout)
253
254 if not success:
--> 255 raise response
256 return response
257
httperror_seek_wrapper: HTTP Error 404: Not Found