output输出问题
为什么爬取的内容是字节码的格式?
为什么爬取的内容是字节码的格式?
2016-03-16
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("<head>")
fout.write('<meta charset="UTF-8">')
fout.write("</head>")
fout.write("<body>")
fout.write("<table>")
#ascii
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("</table>")
fout.write("</body>")
fout.write("</html>")
举报