Python3使用urllib爬取简单页面

 时间:2024-11-15 13:44:05

1、打开Python开发工具IDLE,新建‘url.py’文件,编写代码如下:from urllib.request import urlopenresp = urlopen('http://www.baidu.com')print (resp.read())

Python3使用urllib爬取简单页面

3、改写代码,打印百度返回状态码from urllib.request import urlopenresp = urlopen('http://www.baidu.com')print (resp.getcode())

Python3使用urllib爬取简单页面

5、改写代码,打印请求url地址from urllib.request import urlopenresp = urlopen('稆糨孝汶;http://www.baidu.com')print (resp.getcode())print (resp.geturl())

Python3使用urllib爬取简单页面

7、改写代码,打印返回头部信息from urllib.request import urlopenresp = urlopen烫喇霰嘴('http://www.baidu.com')print (resp.getcode())print (resp.geturl())print (resp.info())

Python3使用urllib爬取简单页面
  • win10更新后无法上网解决方法
  • 怎么设置下载速度
  • win11怎么修改ip地址
  • 显卡怎么拆下来
  • Windows11如何设置新网络
  • 热门搜索
    泰国什么东西值得买 现在什么网游最赚钱 额头大适合什么发型 义愤填膺是什么意思 吃火龙果什么好处 即兴的意思 石榴木命什么意思 广漠的意思 送爸爸什么礼物最好 专技12级是什么意思