SBB icon indicating copy to clipboard operation
SBB copied to clipboard

Exception handling required for urllib2

Open wenjiandu opened this issue 9 years ago • 0 comments

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

wenjiandu avatar Apr 17 '15 14:04 wenjiandu