1
0
mirror of https://github.com/searxng/searxng.git synced 2024-11-05 12:50:11 +01:00
searxng/searx/engines/apkmirror.py

67 lines
1.7 KiB
Python
Raw Normal View History

# SPDX-License-Identifier: AGPL-3.0-or-later
2019-02-13 00:37:29 +01:00
"""
APK Mirror
"""
from urllib.parse import urlencode
2019-02-13 00:37:29 +01:00
from lxml import html
from searx.utils import extract_text, eval_xpath_list, eval_xpath_getindex
# about
about = {
"website": 'https://www.apkmirror.com',
"wikidata_id": None,
"official_api_documentation": None,
"use_official_api": False,
"require_api_key": False,
"results": 'HTML',
}
2019-02-13 00:37:29 +01:00
# 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
2021-02-09 11:02:12 +01:00
for result in eval_xpath_list(dom, './/div[@id="content"]/div[@class="listWidget"]//div[@class="appRow"]'):
2019-02-13 00:37:29 +01:00
link = eval_xpath_getindex(result, './/h5/a', 0)
2019-02-13 00:37:29 +01:00
url = base_url + link.attrib.get('href') + '#downloads'
title = extract_text(link)
thumbnail_src = base_url\
+ eval_xpath_getindex(result, './/img', 0).attrib.get('src').replace('&w=32&h=32', '&w=64&h=64')
2019-02-13 00:37:29 +01:00
res = {
'url': url,
'title': title,
'thumbnail_src': thumbnail_src
}
# append result
results.append(res)
# return results
return results