summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorallendema_searxng_pi <pi@raspberrypi.local>2023-08-03 19:15:24 +0200
committerMarkus Heiser <markus.heiser@darmarIT.de>2023-08-09 07:17:40 +0200
commitc00c0c54343e16540439341158affaf78b130c19 (patch)
tree5bcc19189965b2a487ea0ae30854b8b232340fca
parentb8352eca0c23b00993a2f1bc659d98022dc07894 (diff)
downloadsearxng-c00c0c54343e16540439341158affaf78b130c19.tar.gz
searxng-c00c0c54343e16540439341158affaf78b130c19.zip
[mod] remove discontinued petalsearch engines
-rw-r--r--searx/engines/petal_images.py94
-rw-r--r--searx/settings.yml27
2 files changed, 0 insertions, 121 deletions
diff --git a/searx/engines/petal_images.py b/searx/engines/petal_images.py
deleted file mode 100644
index 88853c1bd..000000000
--- a/searx/engines/petal_images.py
+++ /dev/null
@@ -1,94 +0,0 @@
-# SPDX-License-Identifier: AGPL-3.0-or-later
-"""Petalsearch Images
-
-"""
-
-from json import loads
-from urllib.parse import urlencode
-from datetime import datetime
-
-from lxml import html
-
-from searx.utils import extract_text
-
-about = {
- "website": 'https://petalsearch.com/',
- "wikidata_id": 'Q104399280',
- "official_api_documentation": False,
- "use_official_api": False,
- "require_api_key": False,
- "results": 'JSON',
-}
-
-categories = ['images']
-paging = True
-time_range_support = False
-
-safesearch = True
-safesearch_table = {0: 'off', 1: 'moderate', 2: 'on'}
-
-base_url = 'https://petalsearch.com/'
-search_string = 'search?{query}&channel=image&ps=50&pn={page}&region={lang}&ss_mode={safesearch}&ss_type=normal'
-
-
-def request(query, params):
-
- search_path = search_string.format(
- query=urlencode({'query': query}),
- page=params['pageno'],
- lang=params['language'].lower(),
- safesearch=safesearch_table[params['safesearch']],
- )
-
- params['url'] = base_url + search_path
-
- return params
-
-
-def response(resp):
- results = []
-
- tree = html.fromstring(resp.text)
- root = tree.findall('.//script[3]')
-
- # Convert list to JSON
- json_content = extract_text(root)
-
- # Manipulate with JSON
- data = loads(json_content)
-
- for result in data['newImages']:
- url = result['url']
- title = result['title']
- thumbnail_src = result['image']
-
- pic_dict = result.get('extrainfo')
-
- date_from_api = pic_dict.get('publish_time')
- width = pic_dict.get('width')
- height = pic_dict.get('height')
- img_src = pic_dict.get('real_url')
-
- # Continue if img_src is missing
- if img_src is None or '':
- continue
-
- # Get and convert published date
- if date_from_api is not None:
- publishedDate = datetime.fromtimestamp(int(date_from_api))
-
- # Append results
- results.append(
- {
- 'template': 'images.html',
- 'url': url,
- 'title': title,
- 'img_src': img_src,
- 'thumbnail_src': thumbnail_src,
- 'width': width,
- 'height': height,
- 'publishedDate': publishedDate,
- }
- )
-
- return results
diff --git a/searx/settings.yml b/searx/settings.yml
index 04ec3e466..2ac29351d 100644
--- a/searx/settings.yml
+++ b/searx/settings.yml
@@ -1845,33 +1845,6 @@ engines:
categories: news
brave_category: news
- - name: petalsearch
- shortcut: pts
- engine: xpath
- paging: true
- search_url: https://petalsearch.com/search?query={query}&pn={pageno}
- url_xpath: //div[@class='card-source']
- title_xpath: //div[@class='title-name']
- content_xpath: //div[@class='webpage-text']
- first_page_num: 1
- disabled: true
- headers:
- User-Agent: Mozilla/5.0 (Linux; Android 7.0;) \
- AppleWebKit/537.36 (KHTML, like Gecko) \
- Mobile Safari/537.36 (compatible; PetalBot;+https://webmaster.petalsearch.com/site/petalbot)
- about:
- website: https://petalsearch.com/
- wikidata_id: Q104399280
- use_official_api: false
- require_api_key: false
- results: HTML
-
- - name: petalsearch images
- engine: petal_images
- shortcut: ptsi
- disabled: true
- timeout: 3.0
-
- name: lib.rs
shortcut: lrs
engine: xpath