mirror of https://github.com/searx/searx
Skip result in Semantic Scholar engine if URL is missing
This commit is contained in:
parent
e2ab703f3e
commit
c56f2f1d6b
|
@ -5,7 +5,10 @@
|
|||
|
||||
from json import dumps, loads
|
||||
|
||||
from searx import logger
|
||||
|
||||
|
||||
logger = logger.getChild('semantic scholar')
|
||||
search_url = 'https://www.semanticscholar.org/api/1/search'
|
||||
|
||||
|
||||
|
@ -33,6 +36,10 @@ def response(resp):
|
|||
res = loads(resp.text)
|
||||
results = []
|
||||
for result in res['results']:
|
||||
if 'primaryPaperLink' not in result or 'url' not in result['primaryPaperLink']:
|
||||
logger.debug('ignore result because of missing link: %s', result)
|
||||
continue
|
||||
|
||||
results.append({
|
||||
'url': result['primaryPaperLink']['url'],
|
||||
'title': result['title']['text'],
|
||||
|
|
Loading…
Reference in New Issue