输出爬虫内容的编码问题
编码问题怎么解决呀?
<meta charset='utf-8'>怎么加进去
编码问题怎么解决呀?
<meta charset='utf-8'>怎么加进去
2016-11-03
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>") for data in self.datas: print(data['title']) 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("</table>") fout.write("</body>") fout.write("</html>")
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>") for data in self.datas: print(data['title']) 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("</table>") fout.write("</body>") fout.write("</html>")
亲测
举报