python爬虫(五)图片下载爬虫
来源:互联网 发布:监控无网络视频怎么办 编辑:程序博客网 时间:2024/05/21 09:09
在网页的源代码中,图片的信息在<img> 标签中 其中<img src=>中表明图片所在地址,<img class=>表明图片类型,如表情图片,正常图片,还是广告图片
#--*coding:utf-8import urllibimport re #正则表达式def get_content(url):"""获得文档"""html = urllib.urlopen(url)content = html.read()html.close()return contentdef get_images(info):"""<img class ="BDE_Image" src="http://" pic_ext="jpeg" changedsize="true" width="50" height="373">"""regex = r'class="BDE_Image" src="(.+?\.jpg)"'pat = re.compile(regex)i = 0images_code = re.findall(pat,info)#print len(images_code)for image_url in images_code:print image_urlurllib.urlretrieve(image_url,'%s.jpg'%i)i +=1url = "https://tieba.baidu.com/p/2772656630"info = get_content(url)print get_images(info)
阅读全文
0 0
- python爬虫(五)图片下载爬虫
- Python爬虫(二)图片下载爬虫
- Python爬虫系列(五)360图库美女图片下载
- python爬虫图片下载
- python爬虫之图片下载
- 一、python爬虫程序入门(图片下载)
- Python网络爬虫(三):图片下载器
- [python][project][爬虫] 堆糖网图片下载
- python简单的图片下载小爬虫
- Python爬虫入门五
- Python网络爬虫(五):爬虫原理总结
- WSWP(用 python写爬虫) 笔记五:并发爬虫
- Python爬虫实践(五):Cookie
- python网络爬虫(五):并发抓取
- python爬虫(五)多页码
- python爬虫系列(五):多线程实例
- python[五]:python爬虫进阶
- Python爬虫开发(五):反爬虫措施以及爬虫编写注意事项
- 题目1534:数组中第K小的数字
- Mybatis中配置Mapper
- mybatis中resultmap和resulttype区别
- C++__运算符重载
- jquery01
- python爬虫(五)图片下载爬虫
- mybatis中#和$的区别
- Latex 表格制作工具
- android.app.Fragment
- -Dmaven.multiModuleProjectDirectory system propery is not set.
- sed与awk
- Git使用详细教程
- 二叉搜索树笔记
- C++__继承和派生