|
@@ -1,8 +1,8 @@
|
1
|
|
-## Startpage (Web)
|
2
|
|
-#
|
|
1
|
+# Startpage (Web)
|
|
2
|
+#
|
3
|
3
|
# @website https://startpage.com
|
4
|
4
|
# @provide-api no (nothing found)
|
5
|
|
-#
|
|
5
|
+#
|
6
|
6
|
# @using-api no
|
7
|
7
|
# @results HTML
|
8
|
8
|
# @stable no (HTML can change)
|
|
@@ -17,8 +17,11 @@ import re
|
17
|
17
|
|
18
|
18
|
# engine dependent config
|
19
|
19
|
categories = ['general']
|
20
|
|
-# there is a mechanism to block "bot" search (probably the parameter qid), require storing of qid's between mulitble search-calls
|
21
|
|
-#paging = False
|
|
20
|
+# there is a mechanism to block "bot" search
|
|
21
|
+# (probably the parameter qid), require
|
|
22
|
+# storing of qid's between mulitble search-calls
|
|
23
|
+
|
|
24
|
+# paging = False
|
22
|
25
|
language_support = True
|
23
|
26
|
|
24
|
27
|
# search-url
|
|
@@ -40,11 +43,12 @@ def request(query, params):
|
40
|
43
|
params['url'] = search_url
|
41
|
44
|
params['method'] = 'POST'
|
42
|
45
|
params['data'] = {'query': query,
|
43
|
|
- 'startat': offset}
|
|
46
|
+ 'startat': offset}
|
44
|
47
|
|
45
|
48
|
# set language if specified
|
46
|
49
|
if params['language'] != 'all':
|
47
|
|
- params['data']['with_language'] = 'lang_' + params['language'].split('_')[0]
|
|
50
|
+ params['data']['with_language'] = ('lang_' +
|
|
51
|
+ params['language'].split('_')[0])
|
48
|
52
|
|
49
|
53
|
return params
|
50
|
54
|
|
|
@@ -54,10 +58,13 @@ def response(resp):
|
54
|
58
|
results = []
|
55
|
59
|
|
56
|
60
|
dom = html.fromstring(resp.content)
|
57
|
|
-
|
|
61
|
+
|
58
|
62
|
# parse results
|
59
|
63
|
for result in dom.xpath(results_xpath):
|
60
|
|
- link = result.xpath(link_xpath)[0]
|
|
64
|
+ links = result.xpath(link_xpath)
|
|
65
|
+ if not links:
|
|
66
|
+ continue
|
|
67
|
+ link = links[0]
|
61
|
68
|
url = link.attrib.get('href')
|
62
|
69
|
title = escape(link.text_content())
|
63
|
70
|
|
|
@@ -66,13 +73,14 @@ def response(resp):
|
66
|
73
|
continue
|
67
|
74
|
|
68
|
75
|
if result.xpath('./p[@class="desc"]'):
|
69
|
|
- content = escape(result.xpath('./p[@class="desc"]')[0].text_content())
|
|
76
|
+ content = escape(result.xpath('./p[@class="desc"]')[0]
|
|
77
|
+ .text_content())
|
70
|
78
|
else:
|
71
|
79
|
content = ''
|
72
|
80
|
|
73
|
81
|
# append result
|
74
|
|
- results.append({'url': url,
|
75
|
|
- 'title': title,
|
|
82
|
+ results.append({'url': url,
|
|
83
|
+ 'title': title,
|
76
|
84
|
'content': content})
|
77
|
85
|
|
78
|
86
|
# return results
|