SearXNG is a free internet metasearch engine which aggregates results from various search services and databases. Users are neither tracked nor profiled.
Python bingbravedegoogleduckduckgogooglemetasearchprivacypythonqwantsearchsearch-enginesearxsearxngstartpageyahoo
minor fixes of pubmed engine
Noémi Ványid20bba6dc74d
diff --git a/searx/engines/pubmed.py b/searx/engines/pubmed.pyindex abb59d2ed..6451f1467 100644--- a/searx/engines/pubmed.py+++ b/searx/engines/pubmed.py@@ -11,9 +11,11 @@More info on api: https://www.ncbi.nlm.nih.gov/books/NBK25501/"""+from flask_babel import gettextfrom lxml import etreefrom datetime import datetime-from searx.url_utils import urlencode, urlopen+from searx.url_utils import urlencode+from searx.poolrequests import getcategories = ['science']@@ -46,12 +48,7 @@ def response(resp):pubmed_retrieve_api_url = 'https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?'\+ 'db=pubmed&retmode=xml&id={pmids_string}'- # handle Python2 vs Python3 management of bytes and strings- try:- pmids_results = etree.XML(resp.text.encode('utf-8'))- except AttributeError:- pmids_results = etree.XML(resp.text)-+ pmids_results = etree.XML(resp.content)pmids = pmids_results.xpath('//eSearchResult/IdList/Id')pmids_string = ''@@ -62,7 +59,7 @@ def response(resp):retrieve_url_encoded = pubmed_retrieve_api_url.format(**retrieve_notice_args)- search_results_xml = urlopen(retrieve_url_encoded).read()+ search_results_xml = get(retrieve_url_encoded).contentsearch_results = etree.XML(search_results_xml).xpath('//PubmedArticleSet/PubmedArticle/MedlineCitation')for entry in search_results:@@ -74,12 +71,12 @@ def response(resp):try:content = entry.xpath('.//Abstract/AbstractText')[0].textexcept:- content = 'No abstract is available for this publication.'+ content = gettext('No abstract is available for this publication.')# If a doi is available, add it to the snipppettry:doi = entry.xpath('.//ELocationID[@EIdType="doi"]')[0].text- content = 'DOI: ' + doi + ' Abstract: ' + content+ content = 'DOI: {doi} Abstract: {content}'.format(doi=doi, content=content)except:passdiff --git a/searx/settings.yml b/searx/settings.ymlindex 8ec5173f5..067a842e4 100644--- a/searx/settings.yml+++ b/searx/settings.yml@@ -464,7 +464,7 @@ engines:engine : pubmedshortcut : pubcategories: science- oa_first : false+ timeout : 3.0- name : qwantengine : qwantdiff --git a/searx/url_utils.py b/searx/url_utils.pyindex 5e9e29190..dcafc3ba8 100644--- a/searx/url_utils.py+++ b/searx/url_utils.py@@ -3,7 +3,6 @@ from sys import version_infoif version_info[0] == 2:from urllib import quote, quote_plus, unquote, urlencodefrom urlparse import parse_qs, parse_qsl, urljoin, urlparse, urlunparse, ParseResult- from urllib2 import urlopenelse:from urllib.parse import (parse_qs,@@ -17,7 +16,6 @@ else:urlunparse,ParseResult)- from urllib.request import urlopen__export__ = (parse_qs,