on master help sign in
[fix] sanitize results
commitd2da51179ab9f55928b15fd97ba2d8ecc5099552 authorasciimoo <asciimoo@gmail.com> dateSat 19 Oct 2013, 20:12 (13 years ago) parentad2ff1f
1 file changed+5−1
searx/engines/startpage.py+5−1
searx/engines/startpage.py+5−1
@@ -1,6 +1,6 @@
11from urllib import quote
22from lxml import html
3−from urlparse import urljoin
3+from urlparse import urljoin, urlparse
44from cgi import escape
55
66base_url = 'https://startpage.com/'
@@ -22,6 +22,10 @@ def response(resp):
2222 for result in dom.xpath('//div[@class="result"]'):
2323 link = result.xpath('.//h3/a')[0]
2424 url = urljoin(base_url, link.attrib.get('href'))
25+ parsed_url = urlparse(url)
26+ # TODO better google link detection
27+ if parsed_url.netloc.find('google.com') >= 0:
28+ continue
2529 title = ' '.join(link.xpath('.//text()'))
2630 content = escape(' '.join(result.xpath('.//p[@class="desc"]//text()')))
2731 results.append({'url': url, 'title': title, 'content': content})