diff options
| author | Bnyro <bnyro@tutanota.com> | 2025-02-26 21:55:27 +0100 |
|---|---|---|
| committer | Markus Heiser <markus.heiser@darmarIT.de> | 2025-03-01 18:01:51 +0100 |
| commit | a51416c7c38b29152412b433dfcc941acb3f3083 (patch) | |
| tree | 56f447591704375d96d66fab59b80d5c58e959c3 /searx/engines | |
| parent | d0022d86d298150d40c59e18da4701a81c8610c7 (diff) | |
[feat] engines: add openclipart.org
Diffstat (limited to 'searx/engines')
| -rw-r--r-- | searx/engines/openclipart.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/searx/engines/openclipart.py b/searx/engines/openclipart.py new file mode 100644 index 000000000..3468fcd5d --- /dev/null +++ b/searx/engines/openclipart.py @@ -0,0 +1,47 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later +"""OpenClipArt (images)""" + +from urllib.parse import urlencode +from lxml import html +from searx.utils import extract_text, eval_xpath, eval_xpath_list + +about = { + "website": 'https://openclipart.org/', + "wikidata_id": 'Q979593', + "official_api_documentation": None, + "use_official_api": False, + "require_api_key": False, + "results": 'HTML', +} + +categories = ['images'] +paging = True + +base_url = "https://openclipart.org" + + +def request(query, params): + args = { + 'query': query, + 'p': params['pageno'], + } + params['url'] = f"{base_url}/search/?{urlencode(args)}" + return params + + +def response(resp): + results = [] + + dom = html.fromstring(resp.text) + + for result in eval_xpath_list(dom, "//div[contains(@class, 'gallery')]/div[contains(@class, 'artwork')]"): + results.append( + { + 'template': 'images.html', + 'url': base_url + extract_text(eval_xpath(result, "./a/@href")), + 'title': extract_text(eval_xpath(result, "./a/img/@alt")), + 'img_src': base_url + extract_text(eval_xpath(result, "./a/img/@src")), + } + ) + + return results |