mirror of
https://github.com/vikstrous/pirate-get
synced 2025-01-25 12:24:20 +01:00
commit
7f8ed245a9
@ -12,6 +12,8 @@ import random
|
|||||||
from HTMLParser import HTMLParser
|
from HTMLParser import HTMLParser
|
||||||
import argparse
|
import argparse
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
|
from StringIO import StringIO
|
||||||
|
import gzip
|
||||||
|
|
||||||
class NoRedirection(urllib2.HTTPErrorProcessor):
|
class NoRedirection(urllib2.HTTPErrorProcessor):
|
||||||
|
|
||||||
@ -84,7 +86,12 @@ def main():
|
|||||||
# Catch the Ctrl-C exception and exit cleanly
|
# Catch the Ctrl-C exception and exit cleanly
|
||||||
try:
|
try:
|
||||||
for page in xrange(pages):
|
for page in xrange(pages):
|
||||||
f = urllib2.urlopen(mirror + '/search/' + args.q.replace(" ", "+") + '/' + str(page) + '/7/0')
|
request = urllib2.Request(mirror + '/search/' + args.q.replace(" ", "+") + '/' + str(page) + '/7/0')
|
||||||
|
request.add_header('Accept-encoding', 'gzip')
|
||||||
|
f = urllib2.urlopen(request)
|
||||||
|
if f.info().get('Content-Encoding') == 'gzip':
|
||||||
|
buf = StringIO(f.read())
|
||||||
|
f = gzip.GzipFile(fileobj=buf)
|
||||||
res = f.read()
|
res = f.read()
|
||||||
found = re.findall(""""(magnet\:\?xt=[^"]*)|<td align="right">([^<]+)</td>""", res)
|
found = re.findall(""""(magnet\:\?xt=[^"]*)|<td align="right">([^<]+)</td>""", res)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user