爬虫乱码情况
爬出来的全是b'\nPython\xef\xbc\x88\xe8\x8b\xb1\xe8\xaf\xad\xe5\x8f\x91\xe9\x9f\xb3乱码,什么情况
爬出来的全是b'\nPython\xef\xbc\x88\xe8\x8b\xb1\xe8\xaf\xad\xe5\x8f\x91\xe9\x9f\xb3乱码,什么情况
2016-01-15
我的运行环境是win7,32位,python3.5.1, 修改解析器代码 把#号后面的语句修改成下行,就好了! def output_html(self): #fout = open('output.html','w') fout = open('output.html','w',encoding='utf-8') #fout.write("<html><meta charset=\"utf-8\" />") fout.write("<head><meta charset=\"utf-8\"></head>") fout.write("<body>") fout.write("<table>") for data in self.datas: fout.write("<tr>") fout.write("<td>%s</td>" % data['url']) #fout.write("<td>%s</td>" % data['title'].encode('utf-8')) fout.write("<td>%s</td>" % data['title'].encode('utf-8').decode("utf-8")) #fout.write("<td>%s</td>" % data['summary'].encode('utf-8')) fout.write("<td>%s</td>" % data['summary'].encode('utf-8').decode("utf-8"))
举报