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

31 lines
883 B
Python
Raw Normal View History

2019-08-02 21:57:58 +02:00
from lxml import html
from searx.engines.xpath import extract_text
from searx.url_utils import quote
2019-08-02 22:35:42 +02:00
categories = ['files']
2019-08-02 21:57:58 +02:00
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