36 doc = html.fromstring(resp.text)
38 images = eval_xpath_list(doc,
'//a[starts-with(@href, "/doc")]//img')
41 for result
in eval_xpath_list(doc,
'//script[@type="text/javascript"]'):
42 info_js = extr(extract_text(result),
'] = ',
'};') +
'}'
48 info_item = loads(info_js)
50 if not info_item.get(
'mediakey'):
53 thumbnail_src = extract_text(eval_xpath(images[result_index],
'./@src'))
54 img_src = thumbnail_src.replace(
'240.jpg',
'640.jpg')
57 if info_item.get(
"width")
and info_item.get(
"height"):
58 resolution = f
'{info_item["width"]}x{info_item["height"]}'
61 'template':
'images.html',
62 'url': f
"{base_url}/doc/{info_item['user_id']}/{info_item['doc_id']}",
63 'title': info_item.get(
'title'),
64 'content': info_item.get(
'content',
''),
65 'resolution': resolution,
66 'publishedDate': datetime.fromtimestamp(int(info_item[
'posted_at'])),
67 'thumbnail_src': thumbnail_src,
73 except JSONDecodeError: