46def response(resp):
47 results = []
48
49 if resp.status_code == 404:
50 return results
51
52 raise_for_httperror(resp)
53
54 dom = html.fromstring(resp.text)
55
56 number_of_results_element = eval_xpath_getindex(
57 dom, '//a[@class="active" and contains(@href,"/suchen/dudenonline")]/span/text()', 0, default=None
58 )
59 if number_of_results_element is not None:
60 number_of_results_string = re.sub('[^0-9]', '', number_of_results_element)
61 results.append({'number_of_results': int(number_of_results_string)})
62
63 for result in eval_xpath_list(dom, '//section[not(contains(@class, "essay"))]'):
64 url = eval_xpath_getindex(result, './/h2/a', 0).get('href')
65 url = urljoin(base_url, url)
66 title = eval_xpath(result, 'string(.//h2/a)').strip()
67 content = extract_text(eval_xpath(result, './/p'))
68
69 results.append({'url': url, 'title': title, 'content': content})
70
71 return results