44def response(resp):
45 results = []
46 dom = html.fromstring(resp.text)
47 for entry in eval_xpath_list(dom, '/html/body/main/div/div/div/form/div/ul/li/a[@class="package-snippet"]'):
48 url = base_url + extract_text(eval_xpath_getindex(entry, './@href', 0))
49 title = extract_text(eval_xpath_getindex(entry, './h3/span[@class="package-snippet__name"]', 0))
50 version = extract_text(eval_xpath_getindex(entry, './h3/span[@class="package-snippet__version"]', 0))
51 created_at = extract_text(
52 eval_xpath_getindex(entry, './h3/span[@class="package-snippet__created"]/time/@datetime', 0)
53 )
54 content = extract_text(eval_xpath_getindex(entry, './p', 0))
55 results.append(
56 {
57 "template": "packages.html",
58 "url": url,
59 "title": title,
60 'package_name': title,
61 "content": content,
62 "version": version,
63 'publishedDate': parser.parse(created_at),
64 }
65 )
66
67 return results