diff options
author | Cqoicebordel <Cqoicebordel@users.noreply.github.com> | 2015-01-31 17:29:22 +0100 |
---|---|---|
committer | Cqoicebordel <Cqoicebordel@users.noreply.github.com> | 2015-01-31 17:29:22 +0100 |
commit | d20ddf9da147647710127385a3ee95ff273d4fea (patch) | |
tree | e9607635f06d1a0d01585a58e9a9132526cb5c43 /searx/engines | |
parent | 787fee6a09f5569f67e7bddaf73d52e159c0431c (diff) | |
download | searxng-d20ddf9da147647710127385a3ee95ff273d4fea.tar.gz searxng-d20ddf9da147647710127385a3ee95ff273d4fea.zip |
Stackoverflow's unit test
Diffstat (limited to 'searx/engines')
-rw-r--r-- | searx/engines/stackoverflow.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/searx/engines/stackoverflow.py b/searx/engines/stackoverflow.py index dcbb1890c..78dba9f68 100644 --- a/searx/engines/stackoverflow.py +++ b/searx/engines/stackoverflow.py @@ -12,6 +12,7 @@ from urlparse import urljoin from cgi import escape from urllib import urlencode from lxml import html +from searx.engines.xpath import extract_text # engine dependent config categories = ['it'] @@ -24,8 +25,7 @@ search_url = url+'search?{query}&page={pageno}' # 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()' +content_xpath = './/div[@class="excerpt"]' # do search-request @@ -46,8 +46,8 @@ def response(resp): 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(title_xpath))) - content = escape(' '.join(result.xpath(content_xpath))) + title = escape(extract_text(link)) + content = escape(extract_text(result.xpath(content_xpath))) # append result results.append({'url': href, |