This repository has been archived on 2019-08-06. You can view files and clone it, but cannot push or open issues/pull-requests.
searx/engines/nibl.py

29 lines
859 B
Python

from lxml import html
from searx.engines.xpath import extract_text
from searx.url_utils import quote
url = 'https://nibl.co.uk/bots.php'
search_url = url + '?search={query}'
def request(query, params):
params['url'] = search_url.format(query=quote(query))
return params
def response(resp):
results = []
dom = html.fromstring(resp.text.encode('utf-8'))
for result in dom.xpath('//tr[starts-with(@class, "botlistitem")]'):
filename = extract_text(result.xpath('td[@class="filename"]/text()'))
href = url + result.xpath('td[@class="filename"]/a/@href')[0]
filesize = result.xpath('td[@class="filesize"]/text()')[0]
results.append({'url': href,
'title': filename,
'filesize': filesize,
'template': 'file.html'})
return results