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

Functions

 request (query, params)
 
 response (resp)
 

Variables

dict about
 
bool paging = True
 
list categories = ['shopping']
 
str base_url = "https://geizhals.de"
 
str sort_order = 'relevance'
 
 SORT_RE = re.compile(r"sort:(\w+)")
 
dict sort_order_map
 

Detailed Description

Geizhals is a German website to compare the price of a product on the
most common German shopping sites and find the lowest price.

The sorting of the search results can be influenced by the following additions
to the search term:

``asc`` or ``price``
  To sort by price in ascending order.

``desc``
  To sort by price in descending order.

Function Documentation

◆ request()

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

Definition at line 47 of file geizhals.py.

47def request(query, params):
48 sort = None
49
50 sort_order_path = SORT_RE.search(query)
51 if sort_order_path:
52 sort = sort_order_map.get(sort_order_path.group(1))
53 query = SORT_RE.sub("", query)
54 logger.debug(query)
55
56 args = {
57 'fs': query,
58 'pg': params['pageno'],
59 'toggle_all': 1, # load item specs
60 'sort': sort,
61 }
62 params['url'] = f"{base_url}/?{urlencode(args)}"
63
64 return params
65
66

◆ response()

searx.engines.geizhals.response ( resp)

Definition at line 67 of file geizhals.py.

67def response(resp):
68 results = []
69
70 dom = html.fromstring(resp.text)
71 for result in eval_xpath_list(dom, "//article[contains(@class, 'listview__item')]"):
72 content = []
73 for spec in eval_xpath_list(result, ".//div[contains(@class, 'specs-grid__item')]"):
74 content.append(f"{extract_text(eval_xpath(spec, './dt'))}: {extract_text(eval_xpath(spec, './dd'))}")
75
76 metadata = [
77 extract_text(eval_xpath(result, ".//div[contains(@class, 'stars-rating-label')]")),
78 extract_text(eval_xpath(result, ".//div[contains(@class, 'listview__offercount')]")),
79 ]
80
81 item = {
82 'template': 'products.html',
83 'url': (
84 base_url + "/" + extract_text(eval_xpath(result, ".//a[contains(@class, 'listview__name-link')]/@href"))
85 ),
86 'title': extract_text(eval_xpath(result, ".//h3[contains(@class, 'listview__name')]")),
87 'content': ' | '.join(content),
88 'thumbnail': extract_text(eval_xpath(result, ".//img[contains(@class, 'listview__image')]/@src")),
89 'metadata': ', '.join(item for item in metadata if item),
90 }
91
92 best_price = extract_text(eval_xpath(result, ".//a[contains(@class, 'listview__price-link')]")).split(" ")
93 if len(best_price) > 1:
94 item["price"] = f"Bestes Angebot: {best_price[1]}€"
95 results.append(item)
96
97 return results

Variable Documentation

◆ about

dict searx.engines.geizhals.about
Initial value:
1= {
2 'website': 'https://geizhals.de',
3 'wikidata_id': 'Q15977657',
4 'use_official_api': False,
5 'official_api_documentation': None,
6 'require_api_key': False,
7 'results': 'HTML',
8 'language': 'de',
9}

Definition at line 23 of file geizhals.py.

◆ base_url

str searx.engines.geizhals.base_url = "https://geizhals.de"

Definition at line 35 of file geizhals.py.

◆ categories

list searx.engines.geizhals.categories = ['shopping']

Definition at line 33 of file geizhals.py.

◆ paging

bool searx.engines.geizhals.paging = True

Definition at line 32 of file geizhals.py.

◆ sort_order

str searx.engines.geizhals.sort_order = 'relevance'

Definition at line 36 of file geizhals.py.

◆ sort_order_map

dict searx.engines.geizhals.sort_order_map
Initial value:
1= {
2 'relevance': None,
3 'price': 'p',
4 'asc': 'p',
5 'desc': '-p',
6}

Definition at line 39 of file geizhals.py.

◆ SORT_RE

searx.engines.geizhals.SORT_RE = re.compile(r"sort:(\w+)")

Definition at line 38 of file geizhals.py.