def __init__(self, url=None):
self.url = url
self.html = None
self.links = []
self.soup = None
self.text = None
self.title = None
req = Request(self.url, headers={'User-Agent': "Magic Browser"})
try:
self.html = urlopen(req)
except URLError as e:
if hasattr(e, 'reason'):
print('We failed to reach a server.')
print('Reason: ', e.reason)
elif hasattr(e, 'code'):
print('The server couldn\'t fulfill the request.')
print('Error code: ', e.code)
评论列表
文章目录