第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定

最后瀏覽器不顯示爬取的內(nèi)容

為什么我可以運(yùn)行,但是瀏覽器中不顯示內(nèi)容

正在回答

3 回答

你可以看看生成的html文件內(nèi)容格式對不對啊

0 回復(fù) 有任何疑惑可以回復(fù)我~

# coding:utf8


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>")

? ? ? ? ? ? fout.write("<td>%s</td>" % data['url'])

? ? ? ? ? ? fout.write("<td>%s</td>" % data['title'].encode('utf-8'))

? ? ? ? ? ? fout.write("<td>%s</td>" % data['summary'].encode('utf-8'))

? ? ? ? ? ? fout.write("</tr>")

? ? ? ??

? ? ? ? fout.write("</table>")

? ? ? ? fout.write("</body>")

? ? ? ? fout.write("</html>")

? ? ? ??

? ? ? ? fout.close()


? ? ? ??

也是輸出只有代碼,沒有爬取的內(nèi)容,求賜教

0 回復(fù) 有任何疑惑可以回復(fù)我~

亂碼怎么破?

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

qq_岳怒扇_0

在html文件里設(shè)置編碼,一般就設(shè)置為utf-8編碼吧。
2016-05-17 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消
Python開發(fā)簡單爬蟲
  • 參與學(xué)習(xí)       227603    人
  • 解答問題       1284    個

本教程帶您解開python爬蟲這門神奇技術(shù)的面紗

進(jìn)入課程

最后瀏覽器不顯示爬取的內(nèi)容

我要回答 關(guān)注問題
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號