mirror of
https://github.com/searxng/searxng.git
synced 2024-11-19 19:00:10 +01:00
[fix] startpage engine : characters with diacritic were preceded by whitespace, and cleaner way to parse the result.
This commit is contained in:
parent
bf56ec4fb1
commit
a2928e8d83
@ -19,14 +19,13 @@ def response(resp):
|
|||||||
global base_url
|
global base_url
|
||||||
results = []
|
results = []
|
||||||
dom = html.fromstring(resp.content)
|
dom = html.fromstring(resp.content)
|
||||||
for result in dom.xpath('//div[@class="result"]'):
|
# ads xpath //div[@id="results"]/div[@id="sponsored"]//div[@class="result"]
|
||||||
|
# not ads : div[@class="result"] are the direct childs of div[@id="results"]
|
||||||
|
for result in dom.xpath('//div[@id="results"]/div[@class="result"]'):
|
||||||
link = result.xpath('.//h3/a')[0]
|
link = result.xpath('.//h3/a')[0]
|
||||||
url = link.attrib.get('href')
|
url = link.attrib.get('href')
|
||||||
parsed_url = urlparse(url)
|
parsed_url = urlparse(url)
|
||||||
# TODO better google link detection
|
title = link.text_content()
|
||||||
if parsed_url.netloc.find('www.google.com') >= 0:
|
content = result.xpath('./p[@class="desc"]')[0].text_content()
|
||||||
continue
|
|
||||||
title = ' '.join(link.xpath('.//text()'))
|
|
||||||
content = escape(' '.join(result.xpath('.//p[@class="desc"]//text()')))
|
|
||||||
results.append({'url': url, 'title': title, 'content': content})
|
results.append({'url': url, 'title': title, 'content': content})
|
||||||
return results
|
return results
|
||||||
|
Loading…
Reference in New Issue
Block a user