.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
cppreference.py
Go to the documentation of this file.
1# SPDX-License-Identifier: AGPL-3.0-or-later
2"""Cppreference
3"""
4from lxml import html
5from searx.utils import eval_xpath
6
7
8about = {
9 "website": "https://en.cppreference.com/",
10 "wikidata_id": None,
11 "official_api_documentation": None,
12 "use_official_api": False,
13 "require_api_key": False,
14 "results": 'HTML',
15}
16
17
18categories = ['it']
19url = 'https://en.cppreference.com/'
20search_url = url + 'mwiki/index.php?title=Special%3ASearch&search={query}'
21
22
23def request(query, params):
24 params['url'] = search_url.format(query=query)
25 return query
26
27
28def response(resp):
29 results = []
30 dom = html.fromstring(resp.text)
31 for result in eval_xpath(dom, '//div[contains(@class, "mw-search-result-heading")]'):
32 results.append(
33 {
34 'url': url + eval_xpath(result, './/a/@href')[0],
35 'title': eval_xpath(result, './/a/text()')[0],
36 }
37 )
38 return results