Commit 4cb338fd authored by prx's avatar prx

fix ugly bug

parent faf23184
......@@ -558,51 +558,44 @@ class TorrentSearch:
leechs = str()
for i in soup.find_all('tbody'):
if sys.version_info > (3, 0):
with ThreadPoolExecutor(max_workers=5) as executor:
for res in executor.map(torrent9_parse_results, i.find_all('td')):
yield res
else:
for z in i.find_all('td'):
yield(torrent9_parse_results(z))
def torrent9_parse_results(d):
baseurl = 'http://www.torrent9.ws'
name = str()
magnet = str()
size = str()
seeds = str()
leechs = str()
if d.find('a'):
href = d.find('a')['href']
# le titre est dans des <span>...
name = [ s.string for s in d.a.find_all('span') ]
name = ' '.join(name)
# get magnet link
ms = do_req_get("{}/{}".format(baseurl,href), "text")
magnetsoup = bs4.BeautifulSoup(ms, "html.parser")
for m in magnetsoup.find_all('a', class_='download'):
if m['href'].startswith('magnet'):
magnet = m['href']
break
else:
if len(size) == 0:
size = d.string
elif len(seeds) == 0:
seeds = d.string
elif len(leechs) == 0:
leechs = d.string
for d in i.find_all('td'):
if d.find('a'):
href = d.find('a')['href']
# le titre est dans des <span>...
name = [ s.string for s in d.a.find_all('span') ]
name = ' '.join(name)
# get magnet link
ms = do_req_get("{}/{}".format(baseurl,href), "text")
magnetsoup = bs4.BeautifulSoup(ms, "html.parser")
for m in magnetsoup.find_all('a', class_='download'):
if m['href'].startswith('magnet'):
magnet = m['href']
break
if sys.version_info < (3, 0):
magnet = magnet.encode('utf-8')
name = name.encode('utf-8')
size = size.encode('utf-8')
else:
if len(size) == 0:
size = d.string
elif len(seeds) == 0:
seeds = d.string
elif len(leechs) == 0:
leechs = d.string
if name != '' and magnet != '' and size != '' and seeds != '' and leechs != '':
if sys.version_info < (3, 0):
magnet = magnet.encode('utf-8')
name = name.encode('utf-8')
size = size.encode('utf-8')
res = {'name': name, 'magnet': magnet, 'size': size, 'seeds': seeds, "leechs": leechs}
name = str()
magnet = str()
size = str()
seeds = str()
leechs = str()
res = {'name': name, 'magnet': magnet, 'size': size, 'seeds': seeds, "leechs": leechs}
return res
yield res
def isohunt_parse_results(z):
"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment