小爬虫——下载给定网页上的图片
2014-01-24 22:54
218 查看
来一个小的程序,学习一下正则表达式和urllib库的运用
转自:http://blog.csdn.net/u011249248/article/category/1476523
转自:http://blog.csdn.net/u011249248/article/category/1476523
# -*- coding: utf-8 -*- import re import urllib def getHtml(url): #找出给出网页的源码 page = urllib.urlopen(url) html = page.read() return html def getImg(html): #正则 reg = r'src="(.*?\.jpg)"' #编译正则 imgre = re.compile(reg) #找出图片地址 imglist = re.findall(imgre,html) #循环遍历 x = 0 for i in imglist: urllib.urlretrieve(i,'%s.jpg' % x) x+=1 html = getHtml(r'http://www.renren.com/') getImg(html)
相关文章推荐
- 小爬虫——下载给定网页上的图片
- 下载给定网页上图片的方法
- python3 网页爬虫图片下载无效链接处理 try except
- Python3.x爬虫下载网页图片的实例讲解
- python爬虫(1)下载任意网页图片
- 一个小爬虫 从网页获取信息(图片下载)
- Python 爬虫5——爬取并下载网页指定规格的图片
- python脚本工具-1 制作爬虫下载网页图片
- [python][爬虫]从网页中下载图片
- 网络爬虫之Scrapy实战四:爬取网页下载图片
- 简单的网络爬虫设计——下载网页图片
- 简单爬虫源码,下载指定网页所有图片
- python爬虫一:必应图片(从网页源代码中找出图片链接然后下载)
- 从给定网页上下载<img src="" />格式的图片,并保存到制指定路径
- Python 爬虫学习 网页图片下载
- 小爬虫-一个网页上的.jpg图片下载下来
- python 网页爬虫,下载网络图片
- Python 爬虫5——爬取并下载网页指定规格的图片
- 【Python】python3实现网页爬虫下载图片