1
0
mirror of https://github.com/vikstrous/pirate-get synced 2025-01-10 10:04:21 +01:00

gzip support

This commit is contained in:
mvpossum 2014-05-11 15:42:18 -03:00
parent f028c3d50d
commit a1246db22a

View File

@ -88,12 +88,11 @@ def main():
for page in xrange(pages):
request = urllib2.Request(mirror + '/search/' + args.q.replace(" ", "+") + '/' + str(page) + '/7/0')
request.add_header('Accept-encoding', 'gzip')
response = urllib2.urlopen(request)
if response.info().get('Content-Encoding') == 'gzip':
buf = StringIO(response.read())
res = gzip.GzipFile(fileobj=buf).read()
else:
res = response.read()
f = urllib2.urlopen(request)
if f.info().get('Content-Encoding') == 'gzip':
buf = StringIO(f.read())
f = gzip.GzipFile(fileobj=buf)
res = f.read()
found = re.findall(""""(magnet\:\?xt=[^"]*)|<td align="right">([^<]+)</td>""", res)
# check for a blocked mirror