summaryrefslogtreecommitdiff
path: root/searx/engines/fdroid.py
diff options
context:
space:
mode:
authorDalf <alex@al-f.net>2019-08-05 15:44:02 +0200
committerDalf <alex@al-f.net>2019-08-05 15:44:02 +0200
commitfcc9587ee9b1a4b31a511a8580f2d534e400e96b (patch)
tree06c9b56d6f9cebc98903abecdb65b7cb25910be5 /searx/engines/fdroid.py
parentfbf6b689ddf310980127db5b1688e8c9b8d2a811 (diff)
downloadsearxng-fcc9587ee9b1a4b31a511a8580f2d534e400e96b.tar.gz
searxng-fcc9587ee9b1a4b31a511a8580f2d534e400e96b.zip
[fix] fdroid engine
Diffstat (limited to 'searx/engines/fdroid.py')
-rw-r--r--searx/engines/fdroid.py29
1 files changed, 14 insertions, 15 deletions
diff --git a/searx/engines/fdroid.py b/searx/engines/fdroid.py
index a6b01a8ee..4066dc716 100644
--- a/searx/engines/fdroid.py
+++ b/searx/engines/fdroid.py
@@ -18,13 +18,13 @@ categories = ['files']
paging = True
# search-url
-base_url = 'https://f-droid.org/'
-search_url = base_url + 'repository/browse/?{query}'
+base_url = 'https://search.f-droid.org/'
+search_url = base_url + '?{query}'
# do search-request
def request(query, params):
- query = urlencode({'fdfilter': query, 'fdpage': params['pageno']})
+ query = urlencode({'q': query, 'page': params['pageno'], 'lang': ''})
params['url'] = search_url.format(query=query)
return params
@@ -35,17 +35,16 @@ def response(resp):
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])
- content = content.replace(title, '', 1).strip()
-
- results.append({'url': url,
- 'title': title,
- 'content': content,
- 'img_src': img_src})
+ for app in dom.xpath('//a[@class="package-header"]'):
+ app_url = app.xpath('./@href')[0]
+ app_title = extract_text(app.xpath('./div/h4[@class="package-name"]/text()'))
+ app_content = extract_text(app.xpath('./div/div/span[@class="package-summary"]')).strip() \
+ + ' - ' + extract_text(app.xpath('./div/div/span[@class="package-license"]')).strip()
+ app_img_src = app.xpath('./img[@class="package-icon"]/@src')[0]
+
+ results.append({'url': app_url,
+ 'title': app_title,
+ 'content': app_content,
+ 'img_src': app_img_src})
return results