summaryrefslogtreecommitdiff
path: root/searx/engines
diff options
context:
space:
mode:
authorta <alt3753.7@gmail.com>2022-06-17 16:13:10 +0700
committerMarkus Heiser <markus.heiser@darmarit.de>2022-06-18 16:02:39 +0200
commit8883aed1327a84a81cfabe90419c27259be12fb6 (patch)
treea1f8d7aa16586e988e676e642e49826370ffe824 /searx/engines
parent189df7db4e26056159cc21109591b813f6c4f4ad (diff)
downloadsearxng-8883aed1327a84a81cfabe90419c27259be12fb6.tar.gz
searxng-8883aed1327a84a81cfabe90419c27259be12fb6.zip
[fix] google play apps engine: implement engines/google_play_apps.py
Diffstat (limited to 'searx/engines')
-rw-r--r--searx/engines/google_play_apps.py68
1 files changed, 68 insertions, 0 deletions
diff --git a/searx/engines/google_play_apps.py b/searx/engines/google_play_apps.py
new file mode 100644
index 000000000..577e4e114
--- /dev/null
+++ b/searx/engines/google_play_apps.py
@@ -0,0 +1,68 @@
+# SPDX-License-Identifier: AGPL-3.0-or-later
+"""
+ Google Play Apps
+"""
+
+from urllib.parse import urlencode
+from lxml import html
+from searx.utils import (
+ eval_xpath,
+ extract_url,
+ extract_text,
+ eval_xpath_list,
+ eval_xpath_getindex,
+)
+
+about = {
+ "website": "https://play.google.com/",
+ "wikidata_id": "Q79576",
+ "use_official_api": False,
+ "require_api_key": False,
+ "results": "HTML",
+}
+
+categories = ["files", "apps"]
+search_url = "https://play.google.com/store/search?{query}&c=apps"
+
+
+def request(query, params):
+ params["url"] = search_url.format(query=urlencode({"q": query}))
+
+ return params
+
+
+def response(resp):
+ results = []
+
+ dom = html.fromstring(resp.text)
+
+ if eval_xpath(dom, '//div[@class="v6DsQb"]'):
+ return []
+
+ spot = eval_xpath_getindex(dom, '//div[@class="ipRz4"]', 0, None)
+ if spot is not None:
+ url = extract_url(eval_xpath(spot, './a[@class="Qfxief"]/@href'), search_url)
+ title = extract_text(eval_xpath(spot, './/div[@class="vWM94c"]'))
+ content = extract_text(eval_xpath(spot, './/div[@class="LbQbAe"]'))
+ img = extract_text(eval_xpath(spot, './/img[@class="T75of bzqKMd"]/@src'))
+
+ results.append({"url": url, "title": title, "content": content, "img_src": img})
+
+ more = eval_xpath_list(dom, '//c-wiz[@jsrenderer="RBsfwb"]//div[@role="listitem"]', min_len=1)
+ for result in more:
+ url = extract_url(eval_xpath(result, ".//a/@href"), search_url)
+ title = extract_text(eval_xpath(result, './/span[@class="DdYX5"]'))
+ content = extract_text(eval_xpath(result, './/span[@class="wMUdtb"]'))
+ img = extract_text(
+ eval_xpath(
+ result,
+ './/img[@class="T75of stzEZd" or @class="T75of etjhNc Q8CSx "]/@src',
+ )
+ )
+
+ results.append({"url": url, "title": title, "content": content, "img_src": img})
+
+ for suggestion in eval_xpath_list(dom, '//c-wiz[@jsrenderer="qyd4Kb"]//div[@class="ULeU3b neq64b"]'):
+ results.append({"suggestion": extract_text(eval_xpath(suggestion, './/div[@class="Epkrse "]'))})
+
+ return results