确定目标:哪个网站哪些网页哪部分数据
分析目标:制定抓取策略——url格式、数据格式、网页编码
编写代码:使用抓取策略结果
使用爬虫抓取
1.要注意Python2与Python3的编解码区别
def output_html(self):
fout = open('output.html','w',encoding='utf-8')
fout.write("<html> ")
fout.write("<meta charset='utf-8'>")
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'])
fout.write("<td>%s</td>" % data['summary'])
fout.write("</tr>")
fout.write("</table>")
fout.write("</body>")
fout.w