49 dom = html.fromstring(resp.text)
51 for result
in eval_xpath_list(dom,
'//li[contains(@class, "searchresult")]'):
53 link = eval_xpath_getindex(result,
'.//div[@class="itemurl"]/a', 0, default=
None)
57 title = result.xpath(
'.//div[@class="heading"]/a/text()')
58 content = result.xpath(
'.//div[@class="subhead"]/text()')
60 "url": extract_text(link),
61 "title": extract_text(title),
62 "content": extract_text(content),
65 date = eval_xpath_getindex(result,
'//div[@class="released"]/text()', 0, default=
None)
67 new_result[
"publishedDate"] = dateparse(date.replace(
"released ",
""))
69 thumbnail = result.xpath(
'.//div[@class="art"]/img/@src')
71 new_result[
'thumbnail'] = thumbnail[0]
73 result_id = parse_qs(urlparse(link.get(
'href')).query)[
"search_item_id"][0]
74 itemtype = extract_text(result.xpath(
'.//div[@class="itemtype"]')).lower()
75 if "album" == itemtype:
76 new_result[
"iframe_src"] = iframe_src.format(type=
'album', result_id=result_id)
77 elif "track" == itemtype:
78 new_result[
"iframe_src"] = iframe_src.format(type=
'track', result_id=result_id)
80 results.append(new_result)