Python爬虫urllib笔记(四)之使用BeautifulSoup爬取百度贴吧
来源:互联网 发布:软件学院毕业设计题目 编辑:程序博客网 时间:2024/06/06 20:40
BeautifulSoup-第三方分析网页内容库--替换正则表达式(有官方中文文档可查看)
提取百度贴吧网页中的楼主发的图片
# -*- coding:utf-8 -# # # BeautifulSoup-第三方分析网页内容库--替换正则表达式(有官方中文文档可查看)# pip install beautifulsoup4import urllibfrom bs4 import BeautifulSoupdef get_content(url): html = urllib.urlopen(url) content = html.read() html.close() return contentdef get_imgs(info):"""<img class="BDE_Image" src="http://imgsrc.baidu.com/forum/w%3D580/sign=4a711e3af1246b607b0eb27cdbf91a35/9c019245d688d43f73ecd19b7a1ed21b0ef43b10.jpg" size="15633" height="900" width="507">"""soup=BeautifulSoup(info)#找出所有img标签--加入样式键对值 用_标识防止关键字冲突all_img=soup.find_all('img', class_='BDE_Image')# i = 0# for img in all_img:# #提取每个代码段的src的地址# print img['src']# #下载文件# urllib.urlretrieve(img['src'],'F:\\data\\pachong\\pic2\\%s.jpg' % i)# i +=1#把所有地址返回成数组形式return [img['src'] for img in all_img]info=get_content("http://tieba.baidu.com/p/4364768066")print get_imgs(info)
0 0
- Python爬虫urllib笔记(四)之使用BeautifulSoup爬取百度贴吧
- python的【爬虫】:使用urllib爬取wiki文章,使用beautifulSoup解析html
- [爬虫] Python爬虫 urllib BeautifulSoup
- python爬虫系列之爬取百度文库(四)
- python学习笔记之爬虫之爬取百度贴吧某一帖子
- Python爬虫实战之爬取百度贴吧帖子
- Python使用urllib库和BeautifulSoup库爬虫总结
- Python 使用BeautifulSoup方式爬虫爬取数据
- BeautifulSoup简单爬取百度贴吧
- Python3爬虫之四简单爬虫架构【爬取百度百科python词条网页】
- python爬虫之爬取百度音乐
- python爬虫之爬取百度音乐
- Python爬虫实例(2)-用BeautifulSoup爬取一个网页上的多张照片(以百度贴吧为例)
- python用urllib爬取百度
- python 网络爬虫学习笔记之beautifulsoup
- python爬虫学习笔记2——百度贴吧帖子爬取
- Python爬虫之urllib简单使用
- python爬虫之BeautifulSoup
- 一位程序员偷偷爬取了近100w个招聘职位数据,然后得出了这些结论
- oracle EXP-00028: 无法打开用于写入的 expdate.dmp
- 如何实现打开网页自动弹出QQ对话框
- Mac Use
- java中字节流和字符流的区别
- Python爬虫urllib笔记(四)之使用BeautifulSoup爬取百度贴吧
- 好基友的开源服务器框架 测试TOLUA必备框架
- 从 bufferevent 实现学习 Libevent 的使用
- C/C++语言中的未定义行为
- Struts2概述
- xUtils工具四大功能模块:操作数据库、HTTP通信等
- oracle EXP-00028: 无法打开用于写入的 expdate.dmp
- three.js实现一个网格
- Unreal输出Log的方法