Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion goose/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
limitations under the License.
"""
import urllib2
import StringIO
import gzip


class HtmlFetcher(object):
Expand Down Expand Up @@ -48,9 +50,16 @@ def get_html(self, url):
headers=self.headers)
# do request
try:
self.result = urllib2.urlopen(
response = urllib2.urlopen(
self.request,
timeout=self.config.http_timeout)
if response.info().get('Content-Encoding') == 'gzip':
buf = StringIO.StringIO(response.read())
f = gzip.GzipFile(fileobj=buf)
self.result = f
else:
self.result = request

except Exception:
self.result = None

Expand Down