2016-03-26 22:50:44 +01:00
|
|
|
"""
|
|
|
|
F-Droid (a repository of FOSS applications for Android)
|
|
|
|
|
|
|
|
@website https://f-droid.org/
|
|
|
|
@provide-api no
|
|
|
|
@using-api no
|
|
|
|
@results HTML
|
|
|
|
@stable no (HTML can change)
|
|
|
|
@parse url, title, content
|
|
|
|
"""
|
|
|
|
|
|
|
|
from lxml import html
|
2016-11-30 18:43:03 +01:00
|
|
|
from searx.engines.xpath import extract_text
|
|
|
|
from searx.url_utils import urlencode
|
2016-03-26 22:50:44 +01:00
|
|
|
|
|
|
|
# engine dependent config
|
|
|
|
categories = ['files']
|
|
|
|
paging = True
|
|
|
|
|
|
|
|
# search-url
|
|
|
|
base_url = 'https://f-droid.org/'
|
|
|
|
search_url = base_url + 'repository/browse/?{query}'
|
|
|
|
|
|
|
|
|
|
|
|
# do search-request
|
|
|
|
def request(query, params):
|
2016-11-30 18:43:03 +01:00
|
|
|
query = urlencode({'fdfilter': query, 'fdpage': params['pageno']})
|
2016-03-26 22:50:44 +01:00
|
|
|
params['url'] = search_url.format(query=query)
|
|
|
|
return params
|
|
|
|
|
|
|
|
|
|
|
|
# get response from search-request
|
|
|
|
def response(resp):
|
|
|
|
results = []
|
|
|
|
|
|
|
|
dom = html.fromstring(resp.text)
|
|
|
|
|
|
|
|
for app in dom.xpath('//div[@id="appheader"]'):
|
|
|
|
url = app.xpath('./ancestor::a/@href')[0]
|
|
|
|
title = app.xpath('./p/span/text()')[0]
|
|
|
|
img_src = app.xpath('.//img/@src')[0]
|
|
|
|
|
|
|
|
content = extract_text(app.xpath('./p')[0])
|
2016-12-09 11:44:24 +01:00
|
|
|
content = content.replace(title, '', 1).strip()
|
2016-03-26 22:50:44 +01:00
|
|
|
|
|
|
|
results.append({'url': url,
|
|
|
|
'title': title,
|
|
|
|
'content': content,
|
|
|
|
'img_src': img_src})
|
|
|
|
|
|
|
|
return results
|