|
@@ -11,6 +11,14 @@ title_xpath = None
|
11
|
11
|
suggestion_xpath = ''
|
12
|
12
|
results_xpath = ''
|
13
|
13
|
|
|
14
|
+# parameters for engines with paging support
|
|
15
|
+#
|
|
16
|
+# number of results on each page
|
|
17
|
+# (only needed if the site requires not a page number, but an offset)
|
|
18
|
+page_size = 1
|
|
19
|
+# number of the first page (usually 0 or 1)
|
|
20
|
+first_page_num = 1
|
|
21
|
+
|
14
|
22
|
|
15
|
23
|
'''
|
16
|
24
|
if xpath_results is list, extract the text from each result and concat the list
|
|
@@ -76,8 +84,14 @@ def normalize_url(url):
|
76
|
84
|
|
77
|
85
|
def request(query, params):
|
78
|
86
|
query = urlencode({'q': query})[2:]
|
79
|
|
- params['url'] = search_url.format(query=query)
|
|
87
|
+
|
|
88
|
+ fp = {'query': query}
|
|
89
|
+ if paging and search_url.find('{pageno}') >= 0:
|
|
90
|
+ fp['pageno'] = (params['pageno'] + first_page_num - 1) * page_size
|
|
91
|
+
|
|
92
|
+ params['url'] = search_url.format(**fp)
|
80
|
93
|
params['query'] = query
|
|
94
|
+
|
81
|
95
|
return params
|
82
|
96
|
|
83
|
97
|
|