1
0
mirror of https://github.com/searxng/searxng.git synced 2024-11-19 19:00:10 +01:00

[fix] duckduckgo unicode url - #419

This commit is contained in:
Adam Tauber 2015-09-07 23:13:04 +02:00
parent 362c849797
commit 4184cece4a
2 changed files with 5 additions and 4 deletions

View File

@ -72,7 +72,7 @@ def response(resp):
# append result # append result
results.append({'title': title, results.append({'title': title,
'content': content, 'content': content,
'url': res_url.encode('utf8')}) 'url': res_url})
# return results # return results
return results return results

View File

@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from collections import defaultdict from collections import defaultdict
import mock import mock
from searx.engines import duckduckgo from searx.engines import duckduckgo
@ -30,7 +31,7 @@ class TestDuckduckgoEngine(SearxTestCase):
response = mock.Mock(text='<html></html>') response = mock.Mock(text='<html></html>')
self.assertEqual(duckduckgo.response(response), []) self.assertEqual(duckduckgo.response(response), [])
html = """ html = u"""
<div class="results_links results_links_deep web-result"> <div class="results_links results_links_deep web-result">
<div class="icon_fav" style="display: block;"> <div class="icon_fav" style="display: block;">
<a rel="nofollow" href="https://www.test.com/"> <a rel="nofollow" href="https://www.test.com/">
@ -39,7 +40,7 @@ class TestDuckduckgoEngine(SearxTestCase):
</a> </a>
</div> </div>
<div class="links_main links_deep"> <!-- This is the visible part --> <div class="links_main links_deep"> <!-- This is the visible part -->
<a rel="nofollow" class="large" href="http://this.should.be.the.link/"> <a rel="nofollow" class="large" href="http://this.should.be.the.link/ű">
This <b>is</b> <b>the</b> title This <b>is</b> <b>the</b> title
</a> </a>
<div class="snippet"><b>This</b> should be the content.</div> <div class="snippet"><b>This</b> should be the content.</div>
@ -54,7 +55,7 @@ class TestDuckduckgoEngine(SearxTestCase):
self.assertEqual(type(results), list) self.assertEqual(type(results), list)
self.assertEqual(len(results), 1) self.assertEqual(len(results), 1)
self.assertEqual(results[0]['title'], 'This is the title') self.assertEqual(results[0]['title'], 'This is the title')
self.assertEqual(results[0]['url'], 'http://this.should.be.the.link/') self.assertEqual(results[0]['url'], u'http://this.should.be.the.link/ű')
self.assertEqual(results[0]['content'], 'This should be the content.') self.assertEqual(results[0]['content'], 'This should be the content.')
html = """ html = """