python中使用urllib下载网站图片
2014-03-11 16:29
561 查看
在python中可以使用urllib方便的实现图片和flash下载,测试:
import urllib
url = "http://www.udooo.com/cooperate/qq/images/081128/left.swf"
path = "c:/spider/left.swf"
data = urllib.urlopen(url).read()
f = file(path,"wb")
f.write(data)
f.close()
python中还有更简洁的方法:
import urllib
url = r"http://www.udooo.com/cooperate/qq/images/081128/left.swf"
path = r"c:/spider/left2.swf"
data = urllib.urlretrieve(url,path)
urllib是python中内置的模块。不需要另外下载
import urllib
url = "http://www.udooo.com/cooperate/qq/images/081128/left.swf"
path = "c:/spider/left.swf"
data = urllib.urlopen(url).read()
f = file(path,"wb")
f.write(data)
f.close()
python中还有更简洁的方法:
import urllib
url = r"http://www.udooo.com/cooperate/qq/images/081128/left.swf"
path = r"c:/spider/left2.swf"
data = urllib.urlretrieve(url,path)
urllib是python中内置的模块。不需要另外下载
相关文章推荐
- Python 列表(List)操作方法详解
- Python - twisted web 入门学习之一
- python urllib2的proxyhandler
- 是什么让Python如此杰出?
- 使用Eclipse与Pydev开发Python
- python yield
- python学习笔记之(六)
- Python 多线程
- Python基本数据类型详细介绍
- 【Python】Error:unident does not match any outer indentation level
- Python-基础-内置函数小结
- python模块安装
- python 程序生成exe文件
- 常用python数据类型转换函数总结
- python读取csv文件示例(python操作csv)
- python 生成 html文件
- Python类变量和实例变量区别
- 《Head First Python》学习笔记1
- Python help()函数用法详解
- 输出包含共同元素的变量值 分类: python 小练习 python基础学习 2014-03-11 13:55 188人阅读 评论(0) 收藏