-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhtml_outputer.py
More file actions
38 lines (30 loc) · 1011 Bytes
/
html_outputer.py
File metadata and controls
38 lines (30 loc) · 1011 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
__author__ = 'Gary'
# 输出器
class HtmlOutputer(object):
def __init__(self):
self.datas = []
def collect_data(self, data):
if data is None:
return
self.datas.append(data)
def output_html(self):
fout = open('output.html', 'w', encoding='utf-8')
fout.write("<html>")
fout.write("<body>")
#fout.write("<table>")
fout.write("<a>")
for data in self.datas:
# fout.write("<tr>")
# fout.write("<td>%s</td>" % data['url'])
# fout.write("<td>%s</td>" % data['title'])
# fout.write("<td>%s</td>" % data['summary'])
# fout.write("</tr>")
fout.write('<a href="%s">%s</a>' % (data['url'], data['title']))
fout.write('<p>%s</p>' % data['summary'])
fout.write("</a>")
#fout.write("</table>")
fout.write("</body>")
fout.write("</html>")
fout.close()