Przeglądaj źródła

[ehn] added ixquick engine, using startpage engine

pw3t 11 lat temu
rodzic
commit
a01042ae61
2 zmienionych plików z 15 dodań i 3 usunięć
  1. 8
    3
      searx/engines/startpage.py
  2. 7
    0
      searx/settings_robot.yml

+ 8
- 3
searx/engines/startpage.py Wyświetl plik

1
 from urllib import urlencode
1
 from urllib import urlencode
2
 from lxml import html
2
 from lxml import html
3
 
3
 
4
-base_url = 'https://startpage.com/'
5
-search_url = base_url+'do/search'
4
+base_url = None
5
+search_url = None
6
 
6
 
7
 
7
 
8
 def request(query, params):
8
 def request(query, params):
24
         link = result.xpath('.//h3/a')[0]
24
         link = result.xpath('.//h3/a')[0]
25
         url = link.attrib.get('href')
25
         url = link.attrib.get('href')
26
         title = link.text_content()
26
         title = link.text_content()
27
-        content = result.xpath('./p[@class="desc"]')[0].text_content()
27
+
28
+        content =''
29
+        if len(result.xpath('./p[@class="desc"]')):
30
+            content = result.xpath('./p[@class="desc"]')[0].text_content()
31
+        
28
         results.append({'url': url, 'title': title, 'content': content})
32
         results.append({'url': url, 'title': title, 'content': content})
33
+    
29
     return results
34
     return results

+ 7
- 0
searx/settings_robot.yml Wyświetl plik

68
 
68
 
69
   - name : startpage
69
   - name : startpage
70
     engine : startpage
70
     engine : startpage
71
+    base_url : 'https://startpage.com/'
72
+    search_url : 'https://startpage.com/do/search'
73
+
74
+  - name : ixquick
75
+    engine : startpage
76
+    base_url : 'https://www.ixquick.com/'
77
+    search_url : 'https://www.ixquick.com/do/search'
71
 
78
 
72
   - name : twitter
79
   - name : twitter
73
     engine : twitter
80
     engine : twitter