Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
html_downloader.py下载器
import urllib2
class HtmlDownloader(object):
def download(self, url):
if url is None:
print 'url is None'
return None
try:
response = urllib2.urlopen(url, timeout=10)
if response.getcode() != 200:
print 'false'
return None
print 'success'
except:
print 'timeout'
return response.read()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.