.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
svgrepo.py
Go to the documentation of this file.
1# SPDX-License-Identifier: AGPL-3.0-or-later
2"""Svgrepo (images)
3"""
4
5from lxml import html
6from searx.utils import extract_text, eval_xpath, eval_xpath_list
7
8about = {
9 "website": 'https://www.svgrepo.com',
10 "official_api_documentation": 'https://svgapi.com',
11 "use_official_api": False,
12 "require_api_key": False,
13 "results": 'HTML',
14}
15
16paging = True
17categories = ['images']
18base_url = "https://www.svgrepo.com"
19
20results_xpath = "//div[@class='style_nodeListing__7Nmro']/div"
21url_xpath = ".//a/@href"
22title_xpath = ".//a/@title"
23img_src_xpath = ".//img/@src"
24
25
26def request(query, params):
27 params['url'] = f"{base_url}/vectors/{query}/{params['pageno']}/"
28 return params
29
30
31def response(resp):
32 results = []
33
34 dom = html.fromstring(resp.text)
35 for result in eval_xpath_list(dom, results_xpath):
36 results.append(
37 {
38 'template': 'images.html',
39 'url': base_url + extract_text(eval_xpath(result, url_xpath)),
40 'title': extract_text(eval_xpath(result, title_xpath)).replace(" SVG File", "").replace("Show ", ""),
41 'img_src': extract_text(eval_xpath(result, img_src_xpath)),
42 }
43 )
44
45 return results
request(query, params)
Definition svgrepo.py:26