on master help sign in
Merge branch 'master' into master
aeb6dabNoémi Ványi
searx/engines/bing_images.py+1−3
@@ -88,9 +88,7 @@ def response(resp):
88
88
89 url = json_data.get('purl')
89 url = json_data.get('purl')
90 img_src = json_data.get('murl')
90 img_src = json_data.get('murl')
91−
92− thumb_json_data = loads(_quote_keys_regex.sub(r'\1"\2": \3', link.attrib.get('mad')))
93− thumbnail = thumb_json_data.get('turl')
91+ thumbnail = json_data.get('turl')
94
92
95 # append result
93 # append result
96 results.append({'template': 'images.html',
94 results.append({'template': 'images.html',
searx/engines/startpage.py+4−3
@@ -32,8 +32,9 @@ search_url = base_url + 'do/search'
32# specific xpath variables
32# specific xpath variables
33# ads xpath //div[@id="results"]/div[@id="sponsored"]//div[@class="result"]
33# ads xpath //div[@id="results"]/div[@id="sponsored"]//div[@class="result"]
34# not ads: div[@class="result"] are the direct childs of div[@id="results"]
34# not ads: div[@class="result"] are the direct childs of div[@id="results"]
35−results_xpath = '//div[@class="result"]'
35+results_xpath = '//li[contains(@class, "search-result") and contains(@class, "search-item")]'
36link_xpath = './/h3/a'
36link_xpath = './/h3/a'
37+content_xpath = './p[@class="search-item__body"]'
37
38
38
39
39# do search-request
40# do search-request
@@ -75,8 +76,8 @@ def response(resp):
75
76
76 title = extract_text(link)
77 title = extract_text(link)
77
78
78− if result.xpath('./p[@class="desc clk"]'):
79+ if result.xpath(content_xpath):
79− content = extract_text(result.xpath('./p[@class="desc clk"]'))
80+ content = extract_text(result.xpath(content_xpath))
80 else:
81 else:
81 content = ''
82 content = ''
82
83
tests/unit/engines/test_bing_images.py+3−3
@@ -52,7 +52,7 @@ class TestBingImagesEngine(SearxTestCase):
52 <li>
52 <li>
53 <div>
53 <div>
54 <div class="imgpt">
54 <div class="imgpt">
55− <a m='{"purl":"page_url","murl":"img_url"}' mad='{"turl":"thumb_url"}'>
55+ <a m='{"purl":"page_url","murl":"img_url","turl":"thumb_url"}'>
56 <img src="" alt="alt text" />
56 <img src="" alt="alt text" />
57 </a>
57 </a>
58 </div>
58 </div>
@@ -60,7 +60,7 @@ class TestBingImagesEngine(SearxTestCase):
60 </div>
60 </div>
61 <div>
61 <div>
62 <div class="imgpt">
62 <div class="imgpt">
63− <a m='{"purl":"page_url2","murl":"img_url2"}' mad='{"turl":"thumb_url2"}'>
63+ <a m='{"purl":"page_url2","murl":"img_url2","turl":"thumb_url2"}'>
64 <img src="" alt="alt text 2" />
64 <img src="" alt="alt text 2" />
65 </a>
65 </a>
66 </div>
66 </div>
@@ -71,7 +71,7 @@ class TestBingImagesEngine(SearxTestCase):
71 <li>
71 <li>
72 <div>
72 <div>
73 <div class="imgpt">
73 <div class="imgpt">
74− <a m='{"purl":"page_url3","murl":"img_url3"}' mad='{"turl":"thumb_url3"}'>
74+ <a m='{"purl":"page_url3","murl":"img_url3","turl":"thumb_url3"}'>
75 <img src="" alt="alt text 3" />
75 <img src="" alt="alt text 3" />
76 </a>
76 </a>
77 </div>
77 </div>
tests/unit/engines/test_startpage.py+11−11
@@ -31,14 +31,14 @@ class TestStartpageEngine(SearxTestCase):
31 self.assertEqual(startpage.response(response), [])
31 self.assertEqual(startpage.response(response), [])
32
32
33 html = """
33 html = """
34− <div class='result' style=' *width : auto; *margin-right : 10%;'>
34+ <li class="search-result search-item">
35 <h3>
35 <h3>
36 <a href='http://this.should.be.the.link/' id='title_2' name='title_2' >
36 <a href='http://this.should.be.the.link/' id='title_2' name='title_2' >
37 This should be the title
37 This should be the title
38 </a>
38 </a>
39 <span id='title_stars_2' name='title_stars_2'> </span>
39 <span id='title_stars_2' name='title_stars_2'> </span>
40 </h3>
40 </h3>
41− <p class='desc clk'>
41+ <p class="search-item__body">
42 This should be the content.
42 This should be the content.
43 </p>
43 </p>
44 <p>
44 <p>
@@ -56,7 +56,7 @@ class TestStartpageEngine(SearxTestCase):
56 Mis en surbrillance
56 Mis en surbrillance
57 </A>
57 </A>
58 </p>
58 </p>
59− </div>
59+ </li>
60 """
60 """
61 response = mock.Mock(text=html.encode('utf-8'))
61 response = mock.Mock(text=html.encode('utf-8'))
62 results = startpage.response(response)
62 results = startpage.response(response)
@@ -67,14 +67,14 @@ class TestStartpageEngine(SearxTestCase):
67 self.assertEqual(results[0]['content'], 'This should be the content.')
67 self.assertEqual(results[0]['content'], 'This should be the content.')
68
68
69 html = """
69 html = """
70− <div class='result' style=' *width : auto; *margin-right : 10%;'>
70+ <li class="search-result search-item">
71 <h3>
71 <h3>
72 <a href='http://www.google.com/aclk?sa=l&ai=C' id='title_2' name='title_2' >
72 <a href='http://www.google.com/aclk?sa=l&ai=C' id='title_2' name='title_2' >
73 This should be the title
73 This should be the title
74 </a>
74 </a>
75 <span id='title_stars_2' name='title_stars_2'> </span>
75 <span id='title_stars_2' name='title_stars_2'> </span>
76 </h3>
76 </h3>
77− <p class='desc clk'>
77+ <p class="search-item__body">
78 This should be the content.
78 This should be the content.
79 </p>
79 </p>
80 <p>
80 <p>
@@ -92,20 +92,20 @@ class TestStartpageEngine(SearxTestCase):
92 Mis en surbrillance
92 Mis en surbrillance
93 </A>
93 </A>
94 </p>
94 </p>
95− </div>
95+ </li>
96− <div class='result' style=' *width : auto; *margin-right : 10%;'>
96+ <li class="search-result search-item">
97 <h3>
97 <h3>
98 <span id='title_stars_2' name='title_stars_2'> </span>
98 <span id='title_stars_2' name='title_stars_2'> </span>
99 </h3>
99 </h3>
100− <p class='desc clk'>
100+ <p class="search-item__body">
101 This should be the content.
101 This should be the content.
102 </p>
102 </p>
103 <p>
103 <p>
104 <span class='url'>www.speed<b>test</b>.net/fr/
104 <span class='url'>www.speed<b>test</b>.net/fr/
105 </span>
105 </span>
106 </p>
106 </p>
107− </div>
107+ </li>
108− <div class='result' style=' *width : auto; *margin-right : 10%;'>
108+ <li class="search-result search-item">
109 <h3>
109 <h3>
110 <a href='http://this.should.be.the.link/' id='title_2' name='title_2' >
110 <a href='http://this.should.be.the.link/' id='title_2' name='title_2' >
111 This should be the title
111 This should be the title
@@ -127,7 +127,7 @@ class TestStartpageEngine(SearxTestCase):
127 Mis en surbrillance
127 Mis en surbrillance
128 </A>
128 </A>
129 </p>
129 </p>
130− </div>
130+ </li>
131 """
131 """
132 response = mock.Mock(text=html.encode('utf-8'))
132 response = mock.Mock(text=html.encode('utf-8'))
133 results = startpage.response(response)
133 results = startpage.response(response)