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
fix stackoverflow and add comments
Thomas Pointhubera46bbb404225
diff --git a/searx/engines/stackoverflow.py b/searx/engines/stackoverflow.pyindex e24b309c1..edbe74a70 100644--- a/searx/engines/stackoverflow.py+++ b/searx/engines/stackoverflow.py@@ -1,30 +1,58 @@+## Stackoverflow (It)+#+# @website https://stackoverflow.com/+# @provide-api not clear (https://api.stackexchange.com/docs/advanced-search)+#+# @using-api no+# @results HTML+# @stable no (HTML can change)+# @parse url, title, content+from urlparse import urljoinfrom cgi import escapefrom urllib import urlencodefrom lxml import html+# engine dependent configcategories = ['it']+paging = True+# search-urlurl = 'http://stackoverflow.com/'search_url = url+'search?{query}&page={pageno}'-result_xpath = './/div[@class="excerpt"]//text()'-paging = True+# specific xpath variables+results_xpath = '//div[contains(@class,"question-summary")]'+link_xpath = './/div[@class="result-link"]//a|.//div[@class="summary"]//h3//a'+title_xpath = './/text()'+content_xpath = './/div[@class="excerpt"]//text()'+# do search-requestdef request(query, params):params['url'] = search_url.format(query=urlencode({'q': query}),pageno=params['pageno'])+return params+# get response from search-requestdef response(resp):results = []+dom = html.fromstring(resp.text)- for result in dom.xpath('//div[@class="question-summary search-result"]'):- link = result.xpath('.//div[@class="result-link"]//a')[0]++ # parse results+ for result in dom.xpath(results_xpath):+ link = result.xpath(link_xpath)[0]href = urljoin(url, link.attrib.get('href'))- title = escape(' '.join(link.xpath('.//text()')))- content = escape(' '.join(result.xpath(result_xpath)))- results.append({'url': href, 'title': title, 'content': content})+ title = escape(' '.join(link.xpath(title_xpath)))+ content = escape(' '.join(result.xpath(content_xpath)))++ # append result+ results.append({'url': href,+ 'title': title,+ 'content': content})++ # return resultsreturn resultsdiff --git a/searx/settings.yml b/searx/settings.ymlindex 00ea2c339..a08a15403 100644--- a/searx/settings.yml+++ b/searx/settings.yml@@ -90,7 +90,6 @@ engines:- name : stackoverflowengine : stackoverflow- categories : itshortcut : st- name : startpage