@@ -0,0 +1,61 @@
1+"""
2+ APK Mirror
3+
4+ @website https://www.apkmirror.com
5+
6+ @using-api no
7+ @results HTML
8+ @stable no (HTML can change)
9+ @parse url, title, thumbnail_src
10+"""
11+
12+from lxml import html
13+from searx.engines.xpath import extract_text
14+from searx.url_utils import urlencode
15+
16+# engine dependent config
17+categories = ['it']
18+paging = True
19+
20+# I am not 100% certain about this, as apkmirror appears to be a wordpress site,
21+# which might support time_range searching. If you want to implement it, go ahead.
22+time_range_support = False
23+
24+# search-url
25+base_url = 'https://www.apkmirror.com'
26+search_url = base_url + '/?post_type=app_release&searchtype=apk&page={pageno}&{query}'
27+
28+
29+# do search-request
30+def request(query, params):
31+
32+ params['url'] = search_url.format(pageno=params['pageno'],
33+ query=urlencode({'s': query}))
34+ return params
35+
36+
37+# get response from search-request
38+def response(resp):
39+ results = []
40+
41+ dom = html.fromstring(resp.text)
42+
43+ # parse results
44+ for result in dom.xpath('.//div[@id="content"]/div[@class="listWidget"]/div[@class="appRow"]'):
45+
46+ link = result.xpath('.//h5/a')[0]
47+ url = base_url + link.attrib.get('href') + '#downloads'
48+ title = extract_text(link)
49+ thumbnail_src = base_url + result.xpath('.//img')[0].attrib.get('src').replace('&w=32&h=32', '&w=64&h=64')
50+
51+ res = {
52+ 'url': url,
53+ 'title': title,
54+ 'thumbnail_src': thumbnail_src
55+ }
56+
57+ # append result
58+ results.append(res)
59+
60+ # return results
61+ return results