312 '''Build request parameters (see :ref:`engine request`).'''
314 if params[
'language'] !=
'all':
315 lang = params[
'language'][:2]
318 if params.get(
'time_range'):
319 time_range_val = time_range_map.get(params.get(
'time_range'))
320 time_range = time_range_url.format(time_range_val=time_range_val)
323 if params[
'safesearch']:
324 safe_search = safe_search_map[params[
'safesearch']]
327 'query': urlencode({
'q': query})[2:],
329 'pageno': (params[
'pageno'] - 1) * page_size + first_page_num,
330 'time_range': time_range,
331 'safe_search': safe_search,
334 params[
'cookies'].update(cookies)
335 params[
'headers'].update(headers)
337 params[
'url'] = search_url.format(**fp)
338 params[
'method'] = method
343 params[
'data'] = request_body.format(**fp)
345 params[
'soft_max_redirects'] = soft_max_redirects
346 params[
'raise_for_httperror'] =
False
356 title_filter = html_to_text
if title_html_to_text
else identity
357 content_filter = html_to_text
if content_html_to_text
else identity
362 url = query(result, url_query)[0]
363 tmp_result[
'url'] = url_prefix + to_string(url)
365 title = query(result, title_query)[0]
366 tmp_result[
'title'] = title_filter(to_string(title))
371 content = query(result, content_query)[0]
372 tmp_result[
'content'] = content_filter(to_string(content))
374 tmp_result[
'content'] =
""
378 thumbnail_query_result = query(result, thumbnail_query)[0]
379 tmp_result[
'thumbnail'] = thumbnail_prefix + to_string(thumbnail_query_result)
387 '''Scrap *results* from the response (see :ref:`engine results`).'''
390 if no_result_for_http_status
and resp.status_code
in no_result_for_http_status:
393 raise_for_httperror(resp)
398 json = loads(resp.text)
399 is_onion =
'onions' in categories
402 rs = query(json, results_query)
415 tmp_result[
'is_onion'] =
True
417 results.append(tmp_result)
419 if not suggestion_query:
421 for suggestion
in query(json, suggestion_query):
422 results.append({
'suggestion': suggestion})