Skip to content

Exception handling required for urllib2 #1

@wenjiandu

Description

@wenjiandu

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions