python抓取网页中的图片示例


Posted in Python onFebruary 28, 2014
#coding:utf8
import re
import urllib
def getHTML(url):
    page = urllib.urlopen(url)
    html = page.read()
    return html
def getImg(html,imgType):
    reg = r'src="(.*?\.+'+imgType+'!slider)" '
    imgre = re.compile(reg)
    imgList = re.findall(imgre, html)
    x=0
    for imgurl in imgList:
        print imgurl
        urllib.urlretrieve(imgurl, '%s.%s' % (x, imgType))
        x =x+1

html= getHTML("https://3water.com")
getImg(html,'jpg')
Python 相关文章推荐
python中List的sort方法指南
Sep 01 Python
Python3中常用的处理时间和实现定时任务的方法的介绍
Apr 07 Python
Python 序列的方法总结
Oct 18 Python
vscode 远程调试python的方法
Dec 01 Python
python3 requests中使用ip代理池随机生成ip的实例
May 07 Python
python+POP3实现批量下载邮件附件
Jun 19 Python
Python常见数字运算操作实例小结
Mar 22 Python
Python进程间通信 multiProcessing Queue队列实现详解
Sep 23 Python
使用python将微信image下.dat文件解密为.png的方法
Nov 30 Python
python基于OpenCV模板匹配识别图片中的数字
Mar 31 Python
Django实现翻页的示例代码
May 24 Python
Anaconda配置各版本Pytorch的实现
Aug 07 Python
使用python分析git log日志示例
Feb 27 #Python
python去掉字符串中重复字符的方法
Feb 27 #Python
tornado捕获和处理404错误的方法
Feb 26 #Python
python为tornado添加recaptcha验证码功能
Feb 26 #Python
python实现博客文章爬虫示例
Feb 26 #Python
python处理中文编码和判断编码示例
Feb 26 #Python
python实现网页链接提取的方法分享
Feb 25 #Python
You might like
Yii核心组件AssetManager原理分析
2014/12/02 PHP
php使用Jpgraph绘制柱形图的方法
2015/06/10 PHP
php有效防止同一用户多次登录
2015/11/19 PHP
PDO::getAttribute讲解
2019/01/28 PHP
php在linux环境中如何使用redis详解
2020/12/15 PHP
使用Post提交时须将空格转换成加号的解释
2013/01/14 Javascript
如何让浏览器支持jquery ajax load 前进、后退功能
2014/06/12 Javascript
javascript实现移动端上的触屏拖拽功能
2016/03/04 Javascript
JS简单实现禁止访问某个页面的方法
2016/09/13 Javascript
AngularJS 文件上传控件 ng-file-upload详解
2017/01/13 Javascript
利用prop-types第三方库对组件的props中的变量进行类型检测
2017/05/02 Javascript
详解vue添加删除元素的方法
2018/06/30 Javascript
JavaScript中AOP的实现与应用
2019/05/06 Javascript
layui监听下拉选框选中值变化的方法(包含监听普通下拉选框)
2019/09/24 Javascript
微信小程序开发(三):返回上一级页面并刷新操作示例【页面栈】
2020/06/01 Javascript
Js跳出两级循环方法代码实例
2020/09/22 Javascript
跟老齐学Python之类的细节
2014/10/13 Python
简单分析Python中用fork()函数生成的子进程
2015/05/04 Python
深入浅析python继承问题
2016/05/29 Python
基于pip install django失败时的解决方法
2018/06/12 Python
python占位符输入方式实例
2019/05/27 Python
Selenium向iframe富文本框输入内容过程图解
2020/04/10 Python
python UIAutomator2使用超详细教程
2021/02/19 Python
2分钟教你实现环形/扇形菜单(基础版)
2020/01/15 HTML / CSS
关于canvas.toDataURL 在iOS运行失败的问题解决
2020/09/16 HTML / CSS
加拿大便宜的隐形眼镜商店:Clearly
2016/09/15 全球购物
英国当代时尚和街头服饰店:18montrose
2018/12/15 全球购物
新西兰优惠网站:Treat Me
2019/07/04 全球购物
正宗的澳大利亚Ugg靴子零售商:UGG Express
2020/04/19 全球购物
请解释流与文件有什么不同
2016/07/29 面试题
高中生学习生活的自我评价
2013/10/09 职场文书
党员一帮一活动总结
2014/07/08 职场文书
企业法人授权委托书
2014/09/25 职场文书
庆祝教师节主题班会
2015/08/17 职场文书
小学体育跳绳课教学反思
2016/02/16 职场文书
优化Mysql查询的示例
2022/04/26 MySQL