.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
apkmirror.py
Go to the documentation of this file.
1# SPDX-License-Identifier: AGPL-3.0-or-later
2"""APKMirror
3"""
4
5# pylint: disable=invalid-name
6
7from urllib.parse import urlencode
8from lxml import html
9
10from searx.utils import (
11 eval_xpath_list,
12 eval_xpath_getindex,
13 extract_text,
14)
15
16about = {
17 "website": 'https://www.apkmirror.com',
18 "wikidata_id": None,
19 "official_api_documentation": None,
20 "use_official_api": False,
21 "require_api_key": False,
22 "results": 'HTML',
23}
24
25# engine dependent config
26categories = ['files', 'apps']
27paging = True
28time_range_support = False
29
30# search-url
31base_url = 'https://www.apkmirror.com'
32search_url = base_url + '/?post_type=app_release&searchtype=apk&page={pageno}&{query}'
33
34
35def request(query, params):
36 params['url'] = search_url.format(
37 pageno=params['pageno'],
38 query=urlencode({'s': query}),
39 )
40 logger.debug("query_url --> %s", params['url'])
41 return params
42
43
44def response(resp):
45 results = []
46
47 dom = html.fromstring(resp.text)
48
49 # parse results
50 for result in eval_xpath_list(dom, "//div[@id='content']//div[@class='listWidget']/div/div[@class='appRow']"):
51
52 link = eval_xpath_getindex(result, './/h5/a', 0)
53
54 url = base_url + link.attrib.get('href') + '#downloads'
55 title = extract_text(link)
56 img_src = base_url + eval_xpath_getindex(result, './/img/@src', 0)
57 res = {'url': url, 'title': title, 'img_src': img_src}
58
59 results.append(res)
60
61 return results
request(query, params)
Definition apkmirror.py:35