summaryrefslogtreecommitdiff
path: root/searx
diff options
context:
space:
mode:
authorspongebob33 <marc.cenon33@gmail.com>2021-03-26 12:22:49 +0100
committerMarkus Heiser <markus@darmarit.de>2021-04-24 08:55:45 +0200
commit7528e38c8a412d9f56eba05b34d2f24f3471f21d (patch)
tree6604826c8bf979061b9b8c8ca0d4c8b188813d84 /searx
parent4863c1933e523b4d053de3bc49b3b466c96411d9 (diff)
downloadsearxng-7528e38c8a412d9f56eba05b34d2f24f3471f21d.tar.gz
searxng-7528e38c8a412d9f56eba05b34d2f24f3471f21d.zip
add core.ac.uk engine
Diffstat (limited to 'searx')
-rw-r--r--searx/engines/core.py63
-rw-r--r--searx/settings.yml9
2 files changed, 72 insertions, 0 deletions
diff --git a/searx/engines/core.py b/searx/engines/core.py
new file mode 100644
index 000000000..99b4b524b
--- /dev/null
+++ b/searx/engines/core.py
@@ -0,0 +1,63 @@
+# SPDX-License-Identifier: AGPL-3.0-or-later
+"""
+
+Core Engine (science)
+
+"""
+
+from json import loads
+from datetime import datetime
+from urllib.parse import urlencode
+
+about = {
+ "website": 'https://core.ac.uk',
+ "wikidata_id": 'Q22661180',
+ "official_api_documentation": 'https://core.ac.uk/documentation/api/',
+ "use_official_api": True,
+ "require_api_key": True,
+ "results": 'JSON',
+}
+
+categories = ['science']
+
+paging = True
+nb_per_page = 20
+
+
+# apikey = ''
+apikey = 'MVBozuTX8QF9I1D0GviL5bCn2Ueat6NS'
+
+
+base_url = 'https://core.ac.uk:443/api-v2/search/'
+search_string = '{query}?page={page}&pageSize={nb_per_page}&apiKey={apikey}'
+
+
+def request(query, params):
+
+ search_path = search_string.format(
+ query=urlencode({'q': query}),
+ nb_per_page=nb_per_page,
+ page=params['pageno'],
+ apikey=apikey)
+
+ params['url'] = base_url + search_path
+ return params
+
+
+def response(resp):
+ results = []
+
+ json_data = loads(resp.text)
+ for result in json_data['data']:
+ time = result['_source']['publishedDate']
+ if time is None:
+ date = datetime.now()
+ else:
+ date = datetime.fromtimestamp(time / 1000)
+ results.append({
+ 'url': result['_source']['urls'][0],
+ 'title': result['_source']['title'],
+ 'content': result['_source']['description'],
+ 'publishedDate': date})
+
+ return results
diff --git a/searx/settings.yml b/searx/settings.yml
index 5e0b4cd7d..4217e5bfa 100644
--- a/searx/settings.yml
+++ b/searx/settings.yml
@@ -272,6 +272,15 @@ engines:
categories : images
shortcut : cce
+ - name : core.ac.uk
+ engine : core
+ categories : science
+ shortcut : cor
+ # get your API key from: https://core.ac.uk/api-keys/register/
+ # api_key : "xxxxxxxx"
+ # set api_key and comment out disabled ..
+ disabled: True
+
- name : crossref
engine : json_engine
paging : True