mirror of
https://github.com/searxng/searxng.git
synced 2025-08-03 10:32:21 +02:00
Kickass' unit test
This commit is contained in:
parent
52a57ee045
commit
8ea749d6ec
3 changed files with 403 additions and 4 deletions
|
@ -13,6 +13,7 @@ from cgi import escape
|
|||
from urllib import quote
|
||||
from lxml import html
|
||||
from operator import itemgetter
|
||||
from searx.engines.xpath import extract_text
|
||||
|
||||
# engine dependent config
|
||||
categories = ['videos', 'music', 'files']
|
||||
|
@ -56,9 +57,8 @@ def response(resp):
|
|||
for result in search_res[1:]:
|
||||
link = result.xpath('.//a[@class="cellMainLink"]')[0]
|
||||
href = urljoin(url, link.attrib['href'])
|
||||
title = ' '.join(link.xpath('.//text()'))
|
||||
content = escape(html.tostring(result.xpath(content_xpath)[0],
|
||||
method="text"))
|
||||
title = extract_text(link)
|
||||
content = escape(extract_text(result.xpath(content_xpath)))
|
||||
seed = result.xpath('.//td[contains(@class, "green")]/text()')[0]
|
||||
leech = result.xpath('.//td[contains(@class, "red")]/text()')[0]
|
||||
filesize = result.xpath('.//td[contains(@class, "nobr")]/text()')[0]
|
||||
|
@ -88,7 +88,7 @@ def response(resp):
|
|||
filesize = int(filesize * 1024 * 1024 * 1024)
|
||||
elif filesize_multiplier == 'MB':
|
||||
filesize = int(filesize * 1024 * 1024)
|
||||
elif filesize_multiplier == 'kb':
|
||||
elif filesize_multiplier == 'KB':
|
||||
filesize = int(filesize * 1024)
|
||||
except:
|
||||
filesize = None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue