python抓取百度首页的方法
作者:MXi4oyu 时间:2023-05-25 13:31:58
本文实例讲述了python抓取百度首页的方法。分享给大家供大家参考。具体实现方法如下:
import urllib
def downURL(url,filename):
try:
fp=urllib.urlopen(url)
except:
print('download error')
return 0
op=open(filename,'wb')
while 1:
s=fp.read()
if not s:
break
op.write(s)
fp.close()
op.close()
return 1
downURL("http://www.baidu.com","C:\\url.txt")
希望本文所述对大家的Python程序设计有所帮助。
标签:python,抓取
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
js修改原型的属性使用介绍
2024-04-10 10:51:03
SQL Server中Update的用法
2008-12-29 13:57:00
python datetime时间格式的相互转换问题
2023-12-22 01:04:29
![](https://img.aspxhome.com/file/2023/7/93677_0s.jpg)
详解pytest实现mark标记功能详细介绍
2022-01-16 23:59:48
![](https://img.aspxhome.com/file/2023/0/69510_0s.png)
Python爬虫基础之爬虫的分类知识总结
2021-12-24 03:20:12
![](https://img.aspxhome.com/file/2023/4/71464_0s.png)
详解如何让Go语言中的反射加快
2024-05-28 15:36:52
介绍讲解MySQL安装下载登录
2010-10-25 20:34:00
使用PyWeChatSpy自动回复微信拍一拍功能的实现代码
2021-08-28 21:15:07
![](https://img.aspxhome.com/file/2023/9/105079_0s.jpg)
golang中如何保证精度的方法
2024-04-26 17:23:22
使用Jupyter notebooks上传文件夹或大量数据到服务器
2023-02-26 11:49:16
PHP PDOStatement::errorCode讲解
2023-06-11 12:40:23
错误22022 SQLServerAgent当前未运行的解决方法
2024-01-27 21:19:32
python根据字典的键来删除元素的方法
2023-05-08 00:58:57
MSSQL存储过程学习笔记一 关于存储过程
2024-01-17 18:59:43
win2008下mysql8.0.11升级mysql8.0.17版本详细步骤
2024-01-13 18:04:32
![](https://img.aspxhome.com/file/2023/6/128046_0s.png)
Python3实现的字典、列表和json对象互转功能示例
2022-11-10 11:04:51
Python基于SMTP发送邮件的方法
2021-07-17 23:42:46
![](https://img.aspxhome.com/file/2023/8/107018_0s.png)
vuecli3.0脚手架搭建及不同的打包环境配置vue.config.js的详细过程
2024-04-30 08:42:13
![](https://img.aspxhome.com/file/2023/8/132998_0s.png)
教你一招完美解决vscode安装go插件失败问题
2024-05-09 09:47:20
![](https://img.aspxhome.com/file/2023/5/127335_0s.png)
如何使用python操作vmware
2023-03-13 17:34:41