下载图片-使用beautifulSoup模块
来源:互联网 发布:小学美术网络教学 编辑:程序博客网 时间:2024/05/02 10:44
图片处理 - 使用beautifulSoup模块
标签(空格分隔): python
使用beautifulSoup模块
使用BeautifulSoup对HTML内容解析之后,HTML内容就变成了结构化数据,可以轻易对其中的DOM元素进行操作,比如获取数据,修改,删除等。
from bs4 import BeautifulSoupimport urllib,urllib2def getContext(url): ''' 获取html ''' html = urllib2.urlopen(url).read() return htmldef getImages(html): soup = BeautifulSoup(html) allPic = soup.findAll('img',class_="BDE_Image") for imgUrl in allPic: print imgUrl['src'] # return a list return [imgUrl['src'] for imgUrl in allPic]def downLoadPicture(urlList): i = 1 for item in urlList: urllib.urlretrieve(item, '%s.jpg' % i) i +=1url = 'http://tieba.baidu.com/p/3932177087' if __name__=='__main__': html = getContext(url) urls = getImages(html) downLoadPicture(urls)
附beautifulSoup中文文档
0 0
- 下载图片-使用beautifulSoup模块
- BeautifulSoup模块的简单使用
- 使用requests模块下载爬虫百度图片
- BeautifulSoup模块
- Beautifulsoup模块
- 使用BeautifulSoup实现的图片爬虫
- BeautifulSoup下载给定URL里的图片(一)
- BeautifulSoup下载给定URL里的图片(二)
- 二.BeautifulSoup多线程下载百思不得姐图片
- 使用requests+beautifulsoup模块实现python网络爬虫功能
- 使用BeautifulSoup模块获取糗事百科上的笑话
- 使用requests+beautifulsoup模块实现python网络爬虫功能
- 使用beautifulsoup
- BeautifulSoup使用
- BeautifulSoup使用
- BeautifulSoup使用
- python中的BeautifulSoup模块
- 安装BeautifulSoup模块
- 重学java23种设计模式(11)享元模式
- SSH整合样例
- CF_26A_AlmostPrime
- Sping IOC依赖注入的5种方式
- C#编程:如何获得当前进程运行路径
- 下载图片-使用beautifulSoup模块
- c++学习笔记(部分语法及c++11新特性)
- OpenGL 着色器语言3.1-3.3
- 多个Activity之间的切换
- C语言——单线程播放多音乐和一些小方法
- 医院网络营销到底该怎么做
- 1057. Stack (30)
- 安迪的第一个字典
- ubuntu10.04编译openjdk7