69 dom = html.fromstring(resp.text)
72 for result
in eval_xpath_list(dom,
'//ol[contains(@class,"searchCenterMiddle")]//li'):
74 url = eval_xpath_getindex(result,
'.//h4/a/@href', 0,
None)
78 title = extract_text(result.xpath(
'.//h4/a'))
79 content = extract_text(result.xpath(
'.//p'))
80 thumbnail = eval_xpath_getindex(result,
'.//img/@data-src', 0,
None)
82 item = {
'url': url,
'title': title,
'content': content,
'thumbnail': thumbnail}
84 pub_date = extract_text(result.xpath(
'.//span[contains(@class,"s-time")]'))
85 ago = AGO_RE.search(pub_date)
87 number = int(ago.group(1))
88 delta = AGO_TIMEDELTA[ago.group(2)]
89 pub_date = datetime.now() - delta * number
92 pub_date = parser.parse(pub_date)
93 except parser.ParserError:
96 if pub_date
is not None:
97 item[
'publishedDate'] = pub_date
100 for suggestion
in eval_xpath_list(dom,
'//div[contains(@class,"AlsoTry")]//td'):
101 results.append({
'suggestion': extract_text(suggestion)})