SearXNG is a free internet metasearch engine which aggregates results from various search services and databases. Users are neither tracked nor profiled.
Python bingbravedegoogleduckduckgogooglemetasearchprivacypythonqwantsearchsearch-enginesearxsearxngstartpageyahoo
[feat] engines: add ipernity (images)
Bnyrof766faca3fa4
diff --git a/searx/engines/ipernity.py b/searx/engines/ipernity.pynew file mode 100644index 000000000..6e5eb7872--- /dev/null+++ b/searx/engines/ipernity.py@@ -0,0 +1,76 @@+# SPDX-License-Identifier: AGPL-3.0-or-later+"""Ipernity (images)"""++from datetime import datetime+from json import loads, JSONDecodeError++from urllib.parse import quote_plus+from lxml import html++from searx.utils import extr, extract_text, eval_xpath, eval_xpath_list++about = {+ 'website': 'https://www.ipernity.com',+ 'official_api_documentation': 'https://www.ipernity.com/help/api',+ 'use_official_api': False,+ 'require_api_key': False,+ 'results': 'HTML',+}++paging = True+categories = ['images']+++base_url = 'https://www.ipernity.com'+page_size = 10+++def request(query, params):+ params['url'] = f"{base_url}/search/photo/@/page:{params['pageno']}:{page_size}?q={quote_plus(query)}"+ return params+++def response(resp):+ results = []++ doc = html.fromstring(resp.text)++ images = eval_xpath_list(doc, '//a[starts-with(@href, "/doc")]//img')++ result_index = 0+ for result in eval_xpath_list(doc, '//script[@type="text/javascript"]'):+ info_js = extr(extract_text(result), '] = ', '};') + '}'++ if not info_js:+ continue++ try:+ info_item = loads(info_js)++ if not info_item.get('mediakey'):+ continue++ thumbnail_src = extract_text(eval_xpath(images[result_index], './@src'))+ img_src = thumbnail_src.replace('240.jpg', '640.jpg')++ resolution = None+ if info_item.get("width") and info_item.get("height"):+ resolution = f'{info_item["width"]}x{info_item["height"]}'++ item = {+ 'template': 'images.html',+ 'url': f"{base_url}/doc/{info_item['user_id']}/{info_item['doc_id']}",+ 'title': info_item.get('title'),+ 'content': info_item.get('content', ''),+ 'resolution': resolution,+ 'publishedDate': datetime.fromtimestamp(int(info_item['posted_at'])),+ 'thumbnail_src': thumbnail_src,+ 'img_src': img_src,+ }+ results.append(item)++ result_index += 1+ except JSONDecodeError:+ continue++ return resultsdiff --git a/searx/settings.yml b/searx/settings.ymlindex da9c8174f..46de5d855 100644--- a/searx/settings.yml+++ b/searx/settings.yml@@ -1072,6 +1072,11 @@ engines:timeout: 3.0disabled: true+ - name: ipernity+ engine: ipernity+ shortcut: ip+ disabled: true+- name: jishoengine: jishoshortcut: js