.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
fdroid.py
Go to the documentation of this file.
1# SPDX-License-Identifier: AGPL-3.0-or-later
2"""
3 F-Droid (a repository of FOSS applications for Android)
4"""
5
6from urllib.parse import urlencode
7from lxml import html
8from searx.utils import extract_text
9
10# about
11about = {
12 "website": 'https://f-droid.org/',
13 "wikidata_id": 'Q1386210',
14 "official_api_documentation": None,
15 "use_official_api": False,
16 "require_api_key": False,
17 "results": 'HTML',
18}
19
20# engine dependent config
21categories = ['files', 'apps']
22paging = True
23
24# search-url
25base_url = 'https://search.f-droid.org/'
26search_url = base_url + '?{query}'
27
28
29# do search-request
30def request(query, params):
31 query = urlencode({'q': query, 'page': params['pageno'], 'lang': ''})
32 params['url'] = search_url.format(query=query)
33 return params
34
35
36# get response from search-request
37def response(resp):
38 results = []
39
40 dom = html.fromstring(resp.text)
41
42 for app in dom.xpath('//a[@class="package-header"]'):
43 app_url = app.xpath('./@href')[0]
44 app_title = extract_text(app.xpath('./div/h4[@class="package-name"]/text()'))
45 app_content = (
46 extract_text(app.xpath('./div/div/span[@class="package-summary"]')).strip()
47 + ' - '
48 + extract_text(app.xpath('./div/div/span[@class="package-license"]')).strip()
49 )
50 thumbnail = app.xpath('./img[@class="package-icon"]/@src')[0]
51
52 results.append({'url': app_url, 'title': app_title, 'content': app_content, 'thumbnail': thumbnail})
53
54 return results
request(query, params)
Definition fdroid.py:30