Python 实现爬取图片
来源:互联网 发布:数据结构c语言课程设计 编辑:程序博客网 时间:2024/06/07 00:01
Python 实现爬取图片
本篇博客实现的是用Python实现爬虫爬取武汉大学教务系统首页的验证码:
下面是简单的实现,分为两部分:
一、从网页上爬取图片;
二、把图片保存到本地;
下面是实现代码:
# coding:utf-8import reimport urllibimport urllib2# 在网页上方爬取图片def scriper(): src ="http://210.42.121.134/" request = urllib2.Request(src) response = urllib2.urlopen(request) result = response.read().decode('gbk') pattern = re.compile('<img id="captcha-img" alt=".*?" src="(.*?)".*?',re.S) items = re.findall(pattern,result) out = "" for item in items: out = item print out i =1 for i in range(1,100): saveImg(src+out,str(i)+".jpg") i +=1# 对爬取的图片进行保存def saveImg(imageURL, fileName): u = urllib.urlopen(imageURL) data = u.read() f = open(fileName, 'wb') f.write(data) print u"保存图片为", fileName f.close()scriper()
阅读全文
0 0
- Python 实现爬取图片
- python +requests 实现爬取百度图片
- 利用Python实现网络爬取图片
- Python爬取图片
- Python爬取图片
- python爬取图片
- python爬取图片
- python爬取图片
- python实现爬取百度贴吧图片
- python实现按主题爬取百度图片
- Python爬取网络图片
- python多线程爬取图片
- python爬取网站图片
- python爬取网页图片
- Python爬取网站图片
- Python 爬取百度图片
- python爬虫爬取图片
- python爬取百度图片
- 为什么?为什么?为什么WA啊!洛谷 [USACO1.1]贪婪的送礼者{已AC}
- 【JavaSE学习笔记】多线程02_Lock,死锁,等待唤醒机制,线程组和线程池,Timer定时器
- 使用反编译后的so文件
- react-native 下编写工具、Public类
- 栈和队列(习题)
- Python 实现爬取图片
- Generous Kefa
- C# 向MySQL数据库存储及读取图片、音乐等文件
- myeclipse中web项目出现红色叹号解决方案
- malloc/free和new/delete
- 【离散化+并查集】POJ_1733_Parity game
- CSS3基础学习 02-应用方式:内联、内部、外部
- Lua5.3 虚拟机指令分析(一)概述
- 涉及AbstractQueuedSynchronizer使用-CountDownLatch等