“”"
@theme 爬虫
@time 2018/12/16
@author lz
@content 爬取python吧的页面
@step
1导入2发出请求3转码4保存
“”"
coding : UTF-8
#1导入网络模块
from urllib import request
url=“http://tieba.baidu.com/f?kw=python&ie=utf-8&pn=0”
#2发送网络请求
response=request.urlopen(url)
#3转码
content=response.read().decode(“utf-8”)
#4保存
name=“1.html”
with open(name,“w”,encoding=“utf-8”) as fp:
fp.write(content)
运行结果: