mirror of https://github.com/searxng/searxng
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
864 B
Python
32 lines
864 B
Python
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}/'
|
|
categories = ['videos', 'music', 'files']
|
|
paging = True
|
|
|
|
|
|
def request(query, params):
|
|
params['url'] = search_url.format(search_term=quote(query), pageno=params['pageno'])
|
|
|
|
return params
|
|
|
|
|
|
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
|