Python3爬取图片
2015-12-23 15:12
489 查看
#coding=utf-8 import urllib.request import re def getHtml(url): page = urllib.request.urlopen(url) html = page.read() return html def getImg(html): html = html.decode('utf-8') reg = r'src="(.+?\.jpg)" pic_ext' imgre = re.compile(reg) imglist = re.findall(imgre,html) x = 0 for imgurl in imglist: urllib.request.urlretrieve(imgurl,'%s.jpg' % x) x+=1 html = getHtml("http://tieba.baidu.com/p/2460150866") getImg(html)
相关文章推荐
- Python爬linkedin——规模在1001-5000的瑞士公司(非官方API)
- python multiprocessing.Pipe() Queue 示例
- python 自学笔记
- 由PYTHONPATH谈起
- python中用gensim做wiki的中文数据word2vector处理
- 安利:pynlpir, nlpir 的python端接口, 通过python 使用nlpir / ictclas 2015
- Python之装饰器
- python栈的实现(入栈,出栈)
- python 字符串操作
- [LeetCode]题解(python):075-Sort Colors
- 每天学点Python之strings
- 每天学点Python之comprehensions
- Python模块
- Python基础教程 第11章: 文件和流 学习笔记
- 学好 Python 的 11 个优秀资源
- Python进阶09 动态类型
- [LeetCode]题解(python):074-Search a 2D Matrix
- Python进阶08 异常处理
- Python进阶07 函数对象
- Python进阶06 循环对象