[fix] engine seznam

This commit is contained in:
Venca24 2023-03-31 16:11:27 +02:00
parent 27611470bf
commit c8d78355ff

View File

@ -30,7 +30,8 @@ base_url = 'https://search.seznam.cz/'
def request(query, params): def request(query, params):
response_index = get(base_url, headers=params['headers'], raise_for_httperror=True) response_index = get(
base_url, headers=params['headers'], raise_for_httperror=True)
dom = html.fromstring(response_index.text) dom = html.fromstring(response_index.text)
url_params = { url_params = {
@ -54,8 +55,9 @@ def response(resp):
results = [] results = []
dom = html.fromstring(resp.content.decode()) dom = html.fromstring(resp.content.decode())
for result_element in eval_xpath_list(dom, '//div[@data-dot="results"]/div'): for result_element in eval_xpath_list(dom, '//div[@id="searchpage-root"]//div[@class="Layout--left"]/div[@class="f2c528"]'):
result_data = eval_xpath_getindex(result_element, './/div[contains(@class, "bec586")]', 0, default=None) result_data = eval_xpath_getindex(
result_element, './/div[@class="c8774a" or @class="e69e8d a11657"]', 0, default=None)
if result_data is None: if result_data is None:
continue continue
title_element = eval_xpath_getindex(result_element, './/h3/a', 0) title_element = eval_xpath_getindex(result_element, './/h3/a', 0)
@ -63,7 +65,7 @@ def response(resp):
{ {
'url': title_element.get('href'), 'url': title_element.get('href'),
'title': extract_text(title_element), 'title': extract_text(title_element),
'content': extract_text(eval_xpath(result_data, './/div[@class="_3eded7"]')), 'content': extract_text(result_data),
} }
) )