forked from Ponysearch/Ponysearch
[feat] engine: implementation of cppreference
This commit is contained in:
parent
1a66bfa66c
commit
b1431e1670
2 changed files with 45 additions and 0 deletions
39
searx/engines/cppreference.py
Normal file
39
searx/engines/cppreference.py
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
# lint: pylint
|
||||||
|
"""Cppreference
|
||||||
|
"""
|
||||||
|
from lxml import html
|
||||||
|
from searx.utils import eval_xpath
|
||||||
|
|
||||||
|
|
||||||
|
about = {
|
||||||
|
"website": "https://en.cppreference.com/",
|
||||||
|
"wikidata_id": None,
|
||||||
|
"official_api_documentation": None,
|
||||||
|
"use_official_api": False,
|
||||||
|
"require_api_key": False,
|
||||||
|
"results": 'HTML',
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
categories = ['it']
|
||||||
|
url = 'https://en.cppreference.com/'
|
||||||
|
search_url = url + 'mwiki/index.php?title=Special%3ASearch&search={query}'
|
||||||
|
|
||||||
|
|
||||||
|
def request(query, params):
|
||||||
|
params['url'] = search_url.format(query=query)
|
||||||
|
return query
|
||||||
|
|
||||||
|
|
||||||
|
def response(resp):
|
||||||
|
results = []
|
||||||
|
dom = html.fromstring(resp.text)
|
||||||
|
for result in eval_xpath(dom, '//div[contains(@class, "mw-search-result-heading")]'):
|
||||||
|
results.append(
|
||||||
|
{
|
||||||
|
'url': url + eval_xpath(result, './/a/@href')[0],
|
||||||
|
'title': eval_xpath(result, './/a/text()')[0],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
return results
|
|
@ -477,6 +477,12 @@ engines:
|
||||||
# # get your API key from: https://core.ac.uk/api-keys/register/
|
# # get your API key from: https://core.ac.uk/api-keys/register/
|
||||||
# api_key: 'unset'
|
# api_key: 'unset'
|
||||||
|
|
||||||
|
- name: cppreference
|
||||||
|
engine: cppreference
|
||||||
|
shortcut: cpp
|
||||||
|
paging: false
|
||||||
|
disabled: true
|
||||||
|
|
||||||
- name: crossref
|
- name: crossref
|
||||||
engine: crossref
|
engine: crossref
|
||||||
shortcut: cr
|
shortcut: cr
|
||||||
|
|
Loading…
Reference in a new issue