Skip to content

Commit

Permalink
use urlib2.Request instrand of HTTPhandler
Browse files Browse the repository at this point in the history
  • Loading branch information
grangier committed Aug 9, 2013
1 parent f6eb9e2 commit 4d1ccaf
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions goose/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,13 @@ def get_html(self, config, url):
"""
if isinstance(url, unicode):
url = url.encode('utf-8')
headers = {} # 'User-Agent' : config.browser_user_agent }
request = urllib2.Request(url, None, headers)
opener = urllib2.build_opener(urllib2.HTTPHandler(config.debug))
opener.addheaders = [('User-agent', config.browser_user_agent)]

headers = {'User-agent': config.browser_user_agent}
request = urllib2.Request(url, headers=headers)

try:
result = opener.open(request).read()
result = urllib2.urlopen(request).read()
except:
return None
# urllib2.HTTPError
# ValueError

return result

0 comments on commit 4d1ccaf

Please sign in to comment.