def print_posts(self):
with open('../data/index.html', 'w') as f:
for post in self.model1.reddit_post_list:
date = str(datetime.fromtimestamp(post.created_utc))
post_url = post.link_url + post.id
post_karma = str(post.score)
f.write('<h3 style="color: #5e9ca0; display: inline;">' + 'username:  ' +
self.model1.reddit_username + '  </h3>\n')
f.write('<h3 style="color: #5e9ca0; display: inline;">' + 'date:  ' + date + '  ' +
'karma:  ' + post_karma + ' </h3>\n')
f.write('<p style="color: #5e9ca0; display: inline;"><a href="' + post_url + '"><img\n')
f.write('src="https://cdn4.iconfinder.com/data/icons/web-links/512/41-512.png" alt="" '
'width="14" height="14" /></a></p>')
f.write('<div class="md">\n')
f.write(post.body_html.encode('utf-8') + '\n')
f.write('</div>\n<hr />\n')
评论列表
文章目录