.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.engines.ask Namespace Reference

Functions

 request (query, params)
 
 response (resp)
 

Variables

dict about
 
list categories = ['general']
 
bool paging = True
 
int max_page = 5
 
str base_url = "https://www.ask.com/web"
 

Detailed Description

Ask.com

Function Documentation

◆ request()

searx.engines.ask.request ( query,
params )

Definition at line 28 of file ask.py.

28def request(query, params):
29
30 query_params = {
31 "q": query,
32 "page": params["pageno"],
33 }
34
35 params["url"] = f"{base_url}?{urlencode(query_params)}"
36 return params
37
38

◆ response()

searx.engines.ask.response ( resp)

Definition at line 39 of file ask.py.

39def response(resp):
40
41 start_tag = 'window.MESON.initialState = {'
42 end_tag = '}};'
43
44 dom = html.fromstring(resp.text)
45 script = utils.eval_xpath_getindex(dom, '//script', 0, default=None).text
46
47 pos = script.index(start_tag) + len(start_tag) - 1
48 script = script[pos:]
49 pos = script.index(end_tag) + len(end_tag) - 1
50 script = script[:pos]
51
52 json_resp = utils.js_variable_to_python(script)
53
54 results = []
55
56 for item in json_resp['search']['webResults']['results']:
57
58 pubdate_original = item.get('pubdate_original')
59 if pubdate_original:
60 pubdate_original = dateutil.parser.parse(pubdate_original)
61 metadata = [item.get(field) for field in ['category_l1', 'catsy'] if item.get(field)]
62
63 results.append(
64 {
65 "url": item['url'].split('&ueid')[0],
66 "title": item['title'],
67 "content": item['abstract'],
68 "publishedDate": pubdate_original,
69 # "thumbnail": item.get('image_url') or None, # these are not thumbs / to large
70 "metadata": ' | '.join(metadata),
71 }
72 )
73
74 return results

Variable Documentation

◆ about

dict searx.engines.ask.about
Initial value:
1= {
2 "website": "https://www.ask.com/",
3 "wikidata_id": 'Q847564',
4 "official_api_documentation": None,
5 "use_official_api": False,
6 "require_api_key": False,
7 "results": "HTML",
8}

Definition at line 10 of file ask.py.

◆ base_url

str searx.engines.ask.base_url = "https://www.ask.com/web"

Definition at line 25 of file ask.py.

◆ categories

list searx.engines.ask.categories = ['general']

Definition at line 20 of file ask.py.

◆ max_page

int searx.engines.ask.max_page = 5

Definition at line 22 of file ask.py.

◆ paging

bool searx.engines.ask.paging = True

Definition at line 21 of file ask.py.