diff options
| author | Adam Tauber <adam.tauber@balabit.com> | 2015-02-02 09:36:43 +0100 |
|---|---|---|
| committer | Adam Tauber <adam.tauber@balabit.com> | 2015-02-02 09:36:43 +0100 |
| commit | 7f865356f9a6c1b40d0c668c59b3d081de618bac (patch) | |
| tree | 60e9acb27577968a41136c04f248c24871e83860 /searx/engines/stackoverflow.py | |
| parent | 03137eebd9fdfaa57452cb364c1bc9f31b243f67 (diff) | |
| parent | 5a16077455ef9e821a2b5f5f7e975be8a37ce83d (diff) | |
Merge branch 'unit-tests' of https://github.com/Cqoicebordel/searx into Cqoicebordel-unit-tests
Conflicts:
searx/tests/test_engines.py
Diffstat (limited to 'searx/engines/stackoverflow.py')
| -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, |