.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.engines.core Namespace Reference

Functions

 request (query, params)
 
 response (resp)
 

Variables

dict about
 
list categories = ['science', 'scientific publications']
 
bool paging = True
 
int nb_per_page = 10
 
str api_key = 'unset'
 
str base_url = 'https://core.ac.uk:443/api-v2/search/'
 
str search_string = '{query}?page={page}&pageSize={nb_per_page}&apiKey={apikey}'
 

Detailed Description

CORE (science)

Function Documentation

◆ request()

searx.engines.core.request ( query,
params )

Definition at line 30 of file core.py.

30def request(query, params):
31
32 if api_key == 'unset':
33 raise SearxEngineAPIException('missing CORE API key')
34
35 search_path = search_string.format(
36 query=urlencode({'q': query}),
37 nb_per_page=nb_per_page,
38 page=params['pageno'],
39 apikey=api_key,
40 )
41 params['url'] = base_url + search_path
42
43 return params
44
45

◆ response()

searx.engines.core.response ( resp)

Definition at line 46 of file core.py.

46def response(resp):
47 results = []
48 json_data = resp.json()
49
50 for result in json_data['data']:
51 source = result['_source']
52 url = None
53 if source.get('urls'):
54 url = source['urls'][0].replace('http://', 'https://', 1)
55
56 if url is None and source.get('doi'):
57 # use the DOI reference
58 url = 'https://doi.org/' + source['doi']
59
60 if url is None and source.get('downloadUrl'):
61 # use the downloadUrl
62 url = source['downloadUrl']
63
64 if url is None and source.get('identifiers'):
65 # try to find an ark id, see
66 # https://www.wikidata.org/wiki/Property:P8091
67 # and https://en.wikipedia.org/wiki/Archival_Resource_Key
68 arkids = [
69 identifier[5:] # 5 is the length of "ark:/"
70 for identifier in source.get('identifiers')
71 if isinstance(identifier, str) and identifier.startswith('ark:/')
72 ]
73 if len(arkids) > 0:
74 url = 'https://n2t.net/' + arkids[0]
75
76 if url is None:
77 continue
78
79 publishedDate = None
80 time = source['publishedDate'] or source['depositedDate']
81 if time:
82 publishedDate = datetime.fromtimestamp(time / 1000)
83
84 # sometimes the 'title' is None / filter None values
85 journals = [j['title'] for j in (source.get('journals') or []) if j['title']]
86
87 publisher = source['publisher']
88 if publisher:
89 publisher = source['publisher'].strip("'")
90
91 results.append(
92 {
93 'template': 'paper.html',
94 'title': source['title'],
95 'url': url,
96 'content': source['description'] or '',
97 # 'comments': '',
98 'tags': source['topics'],
99 'publishedDate': publishedDate,
100 'type': (source['types'] or [None])[0],
101 'authors': source['authors'],
102 'editor': ', '.join(source['contributors'] or []),
103 'publisher': publisher,
104 'journal': ', '.join(journals),
105 # 'volume': '',
106 # 'pages' : '',
107 # 'number': '',
108 'doi': source['doi'],
109 'issn': [x for x in [source.get('issn')] if x],
110 'isbn': [x for x in [source.get('isbn')] if x], # exists in the rawRecordXml
111 'pdf_url': source.get('repositoryDocument', {}).get('pdfOrigin'),
112 }
113 )
114
115 return results

Variable Documentation

◆ about

dict searx.engines.core.about
Initial value:
1= {
2 "website": 'https://core.ac.uk',
3 "wikidata_id": 'Q22661180',
4 "official_api_documentation": 'https://core.ac.uk/documentation/api/',
5 "use_official_api": True,
6 "require_api_key": True,
7 "results": 'JSON',
8}

Definition at line 11 of file core.py.

◆ api_key

str searx.engines.core.api_key = 'unset'

Definition at line 24 of file core.py.

◆ base_url

str searx.engines.core.base_url = 'https://core.ac.uk:443/api-v2/search/'

Definition at line 26 of file core.py.

◆ categories

list searx.engines.core.categories = ['science', 'scientific publications']

Definition at line 20 of file core.py.

◆ nb_per_page

int searx.engines.core.nb_per_page = 10

Definition at line 22 of file core.py.

◆ paging

bool searx.engines.core.paging = True

Definition at line 21 of file core.py.

◆ search_string

str searx.engines.core.search_string = '{query}?page={page}&pageSize={nb_per_page}&apiKey={apikey}'

Definition at line 27 of file core.py.