summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Zohren <jonas.zohren@tu-dortmund.de>2019-02-13 00:37:29 +0100
committerJonas Zohren <jonas.zohren@tu-dortmund.de>2019-02-13 00:37:29 +0100
commitf7bdd827c4cfd92fe182d5806f1e2c35352feed9 (patch)
tree905092653b0f96be8a9def0f70d486332b44af82
parent5fa3c1126ba5f0553001d5c934579d7873e2e673 (diff)
downloadsearxng-f7bdd827c4cfd92fe182d5806f1e2c35352feed9.tar.gz
searxng-f7bdd827c4cfd92fe182d5806f1e2c35352feed9.zip
[enh] adds apkmirror search engine
-rw-r--r--searx/engines/apkmirror.py61
-rw-r--r--searx/settings.yml6
2 files changed, 67 insertions, 0 deletions
diff --git a/searx/engines/apkmirror.py b/searx/engines/apkmirror.py
new file mode 100644
index 000000000..f2ee12b29
--- /dev/null
+++ b/searx/engines/apkmirror.py
@@ -0,0 +1,61 @@
+"""
+ APK Mirror
+
+ @website https://www.apkmirror.com
+
+ @using-api no
+ @results HTML
+ @stable no (HTML can change)
+ @parse url, title, thumbnail_src
+"""
+
+from lxml import html
+from searx.engines.xpath import extract_text
+from searx.url_utils import urlencode
+
+# engine dependent config
+categories = ['it']
+paging = True
+
+# I am not 100% certain about this, as apkmirror appears to be a wordpress site,
+# which might support time_range searching. If you want to implement it, go ahead.
+time_range_support = False
+
+# search-url
+base_url = 'https://www.apkmirror.com'
+search_url = base_url + '/?post_type=app_release&searchtype=apk&page={pageno}&{query}'
+
+
+# do search-request
+def request(query, params):
+
+ params['url'] = search_url.format(pageno=params['pageno'],
+ query=urlencode({'s': query}))
+ return params
+
+
+# get response from search-request
+def response(resp):
+ results = []
+
+ dom = html.fromstring(resp.text)
+
+ # parse results
+ for result in dom.xpath('.//div[@id="content"]/div[@class="listWidget"]/div[@class="appRow"]'):
+
+ link = result.xpath('.//h5/a')[0]
+ url = base_url + link.attrib.get('href') + '#downloads'
+ title = extract_text(link)
+ thumbnail_src = base_url + result.xpath('.//img')[0].attrib.get('src').replace('&w=32&h=32', '&w=64&h=64')
+
+ res = {
+ 'url': url,
+ 'title': title,
+ 'thumbnail_src': thumbnail_src
+ }
+
+ # append result
+ results.append(res)
+
+ # return results
+ return results
diff --git a/searx/settings.yml b/searx/settings.yml
index ff7782b65..3851f49d5 100644
--- a/searx/settings.yml
+++ b/searx/settings.yml
@@ -49,6 +49,12 @@ outgoing: # communication with search engines
# - 1.1.1.2
engines:
+ - name: apk mirror
+ engine: apkmirror
+ timeout: 4.0
+ shortcut: apkm
+ disabled: True
+
- name : arch linux wiki
engine : archlinux
shortcut : al