-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhtml_outputer.py
40 lines (29 loc) · 1.01 KB
/
html_outputer.py
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
38
39
40
#-*-coding: utf-8 -*-
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')
fout.write("<html>")
fout.write("<body>")
fout.write("<table>")
for data in self.datas:
fout.write("<tr>")
#ascii
fout.write("<td>%s</td>"% data['url'].encode('utf-8'))
fout.write("<td>%s</td>" % data['movie_name'].encode('utf-8'))
fout.write("<td>%s</td>" % data['address'].encode('utf-8'))
fout.write("</tr>")
fout.write("</table>")
fout.write("</body>")
fout.write("</html>")
fout.close()
def output_text(self):
f = open("download.txt", "a")
for data in self.datas:
f.write("%s:%s\n\n" % (data['moive_name'].encode('utf-8'), data['address'].encode('utf-8')))
f.close()