“”"
@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)
运行结果:
机器学习之python爬虫爬去百度贴吧一个页面

相关文章:

  • 2021-11-25
  • 2022-01-08
  • 2022-02-13
  • 2021-06-17
  • 2021-07-26
  • 2022-01-29
  • 2022-12-23
猜你喜欢
  • 2021-08-17
  • 2021-06-15
  • 2022-12-23
  • 2022-01-02
  • 2022-01-03
  • 2021-11-11
  • 2021-10-03
相关资源
相似解决方案