50 dom = fromstring(resp.text)
53 first_result_index = page_size * (resp.search_params.get(
'pageno', 1) - 1)
54 all_results = eval_xpath_list(dom, results_xpath)
55 trimmed_results = all_results[first_result_index : first_result_index + page_size]
58 for result
in trimmed_results:
60 raw_url = extract_url(eval_xpath_list(result, url_xpath, min_len=1), search_url)
61 cleaned_url = parse_qs(urlparse(raw_url).query).get(
'redirect_url', [
''])[0]
63 title = extract_text(eval_xpath(result, title_xpath))
64 content = extract_text(eval_xpath(result, content_xpath))
66 results.append({
'url': cleaned_url,
'title': title,
'content': content,
'is_onion':
True})
69 for correction
in eval_xpath_list(dom, correction_xpath):
70 results.append({
'correction': extract_text(correction)})
73 number_of_results = eval_xpath(dom, number_of_results_xpath)
76 results.append({
'number_of_results': int(extract_text(number_of_results))})