SBB
SBB copied to clipboard
Exception handling required for urllib2
While dumping the articles, the script sometimes terminated while executing below codes (Line 101): objResponse = urllib2.urlopen(strTargetBlogPostURL) strPageCode = objResponse.read() objResponse.close()
This is very boring since there's no persistent of artical list. Once the script crashe, we had to retrieve those articals once again. Very time consuming. This issue can be fixed by adding execption handling for it: try: <-- objResponse = urllib2.urlopen(strTargetBlogPostURL) strPageCode = objResponse.read() objResponse.close() except: <-- print " failed to get ", intCounter , ": ", strTargetBlogPostURL pass