61def response(resp):
62 results = []
63 dom = etree.fromstring(resp.content)
64 for entry in eval_xpath_list(dom, xpath_entry):
65 title = eval_xpath_getindex(entry, xpath_title, 0).text
66
67 url = eval_xpath_getindex(entry, xpath_id, 0).text
68 abstract = eval_xpath_getindex(entry, xpath_summary, 0).text
69
70 authors = [author.text for author in eval_xpath_list(entry, xpath_author_name)]
71
72
73 doi_element = eval_xpath_getindex(entry, xpath_doi, 0, default=None)
74 doi = None if doi_element is None else doi_element.text
75
76
77 pdf_element = eval_xpath_getindex(entry, xpath_pdf, 0, default=None)
78 pdf_url = None if pdf_element is None else pdf_element.attrib.get('href')
79
80
81 journal_element = eval_xpath_getindex(entry, xpath_journal, 0, default=None)
82 journal = None if journal_element is None else journal_element.text
83
84
85 tag_elements = eval_xpath(entry, xpath_category)
86 tags = [str(tag) for tag in tag_elements]
87
88
89 comments_elements = eval_xpath_getindex(entry, xpath_comment, 0, default=None)
90 comments = None if comments_elements is None else comments_elements.text
91
92 publishedDate = datetime.strptime(eval_xpath_getindex(entry, xpath_published, 0).text, '%Y-%m-%dT%H:%M:%SZ')
93
94 res_dict = {
95 'template': 'paper.html',
96 'url': url,
97 'title': title,
98 'publishedDate': publishedDate,
99 'content': abstract,
100 'doi': doi,
101 'authors': authors,
102 'journal': journal,
103 'tags': tags,
104 'comments': comments,
105 'pdf_url': pdf_url,
106 }
107
108 results.append(res_dict)
109
110 return results