searxngRebrandZaclys/searx/engines/1337x.py

32 lines
846 B
Python
Raw Normal View History

2017-01-15 13:24:19 +00:00
from urllib import quote
from lxml import html
from searx.engines.xpath import extract_text
from urlparse import urljoin
url = 'https://1337x.to/'
search_url = url + 'search/{search_term}/{pageno}/'
2017-01-15 14:08:43 +00:00
categories = ['videos']
2017-01-15 13:24:19 +00:00
paging = True
2017-01-15 13:50:29 +00:00
2017-01-15 13:24:19 +00:00
def request(query, params):
params['url'] = search_url.format(search_term=quote(query), pageno=params['pageno'])
return params
2017-01-15 13:50:29 +00:00
2017-01-15 13:24:19 +00:00
def response(resp):
results = []
dom = html.fromstring(resp.text)
for result in dom.xpath('//table[contains(@class, "table-list")]/tbody//tr'):
href = urljoin(url, result.xpath('./td[contains(@class, "name")]/a[2]/@href')[0])
title = extract_text(result.xpath('./td[contains(@class, "name")]/a[2]'))
results.append({'url': href,
'title': title,
'content': ''})
return results