手机
当前位置:查字典教程网 >脚本专栏 >python >Python下载指定页面上图片的方法
Python下载指定页面上图片的方法
摘要:本文实例讲述了Python下载指定页面上图片的方法。分享给大家供大家参考,具体如下:#!/usr/bin/python#coding:utf...

本文实例讲述了Python下载指定页面上图片的方法。分享给大家供大家参考,具体如下:

#!/usr/bin/python #coding:utf8 import re import urllib def getHtml(url): page = urllib.urlopen(url) html = page.read() return html def getImg(html): reg = r'src="(.*" ' imgre = re.compile(reg) imglist = re.findall(imgre,html) x = 0 for imgurl in imglist: urllib.urlretrieve(imgurl,'%s.jpg' % x) x += 1 html = getHtml("http://tieba.baidu.com/p/2394357724") getImg(html)

希望本文所述对大家Python程序设计有所帮助。

【Python下载指定页面上图片的方法】相关文章:

Python转码问题的解决方法

python paramiko实现ssh远程访问的方法

python中的yield使用方法

Python中的yield浅析

python使用新浪微博api上传图片到微博示例

Python下singleton模式的实现方法

rhythmbox中文名乱码问题解决方法

Python学习资料

linux下安装easy_install的方法

python 不关闭控制台的实现方法

精品推荐
分类导航