diff options
author | asciimoo <asciimoo@gmail.com> | 2013-10-19 20:12:22 +0200 |
---|---|---|
committer | asciimoo <asciimoo@gmail.com> | 2013-10-19 20:12:22 +0200 |
commit | d2da51179ab9f55928b15fd97ba2d8ecc5099552 (patch) | |
tree | 4fc343d2b66212824194d1468b0e169db5f71ab4 /searx/engines/startpage.py | |
parent | ad2ff1fda8aaaf313f5a1c6131d6bdf2adac9522 (diff) | |
download | searxng-d2da51179ab9f55928b15fd97ba2d8ecc5099552.tar.gz searxng-d2da51179ab9f55928b15fd97ba2d8ecc5099552.zip |
[fix] sanitize results
Diffstat (limited to 'searx/engines/startpage.py')
-rw-r--r-- | searx/engines/startpage.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/searx/engines/startpage.py b/searx/engines/startpage.py index 7242960a4..143bc55b3 100644 --- a/searx/engines/startpage.py +++ b/searx/engines/startpage.py @@ -1,6 +1,6 @@ from urllib import quote from lxml import html -from urlparse import urljoin +from urlparse import urljoin, urlparse from cgi import escape base_url = 'https://startpage.com/' @@ -22,6 +22,10 @@ def response(resp): for result in dom.xpath('//div[@class="result"]'): link = result.xpath('.//h3/a')[0] url = urljoin(base_url, link.attrib.get('href')) + parsed_url = urlparse(url) + # TODO better google link detection + if parsed_url.netloc.find('google.com') >= 0: + continue title = ' '.join(link.xpath('.//text()')) content = escape(' '.join(result.xpath('.//p[@class="desc"]//text()'))) results.append({'url': url, 'title': title, 'content': content}) |