python:beautifulSoup学习(来自学习资料)
来源:互联网 发布:java往word中写入文本 编辑:程序博客网 时间:2024/06/06 03:25
罗列问题:
1、beautifulSoup是什么
是一个能够快速从html或者xml文档中获取数据的类库。
官方的说是,能够帮你节省一天或者几天的开发时间。
2、beautifulSoup如何安装
Pip install beautifulSoup4(如果是Python3.x就是用这个)
旧版本:beautifulSoup3
Pip install beautifulSoup
3、beautifulSoup如何使用
本文中只讲解通过beautifulSoup select选择器获取数据
还有很多其他用法,需要单独学习。
Html基础回顾:
标签:紧跟着尖括号的内容
类:class
属性:标签中的字段
编号:id
html_doc = """<html><head><title>The Dormouse's story</title></head><body><p class="title"><b>The Dormouse's story</b></p><p class="story">Once upon a time there were three little sisters; and their names were<a href="http://example.com/elsie" class="sister" id="link1">Elsie</a>,<a href="http://example.com/lacie" class="sister" id="link2">Lacie</a> and<a href="http://example.com/tillie" class="sister" id="link3">Tillie</a>;and they lived at the bottom of a well.</p><p class="story">...</p>"""
beautifulSoup.select的几种查找数据的方式:
Soup.select(“title”) //通过标签查找Soup.select(“.sister”) //通过class查找Soup.select(“#link2”)//通过id查找Soup.select(“a[href]”) //判断a标签是否有href属性
在python控制台中使用beautifulSoup的部首
1、导入from bs4 import BeautifulSoup
2、创建一个BeautifulSoup的实例
通过标签查找:
通过class查找
Select返回的值是一个list,需要通过角标获取数据。
通过id查找
多个id使用逗号分隔
通过查找
方式一:
属性固定的值
方式二:
是否包含属性
阅读全文
0 0
- python:beautifulSoup学习(来自学习资料)
- python BeautifulSoup基础知识学习
- Python学习-BeautifulSoup模块
- python beautifulsoup 爬虫学习
- python学习笔记(二) BeautifulSoup
- 分布式系统概述(来自学习资料)
- python—BeautifulSoup学习总结
- Python学习笔记:BeautifulSoup模块
- python学习之 beautifulsoup选择器
- python urllib2及beautifulsoup学习
- python module学习之beautifulsoup
- beautifulsoup 学习
- BeautifulSoup学习
- Python学习---BeautifulSoup安装(第三方模块)
- Python爬虫包 BeautifulSoup 学习(一) 简介与安装
- Python爬虫包 BeautifulSoup 学习(二) 异常处理
- Python爬虫包 BeautifulSoup 学习(三) 实例
- Python爬虫包 BeautifulSoup 学习(五) 实例
- jQuery 判断 CheckBox是否被选中
- HDU 1171 Big Event in HDU (多重背包)
- Jboss SpringMVC调用WebService报错:setProperty must be overridden by all subclasses of SOAPMessage
- listview 修改当前item的子控件的属性
- 微信支付-商户后台(3)
- python:beautifulSoup学习(来自学习资料)
- 网页打开速度的心理学
- C++函数模板、类模板
- mybatis进阶(3)--一对一查询(使用resultMap)
- 《程序员健康指南》书摘
- 直接在Dao层进行测试的问题
- 网页特殊符号HTML代码大全
- meta标签详解
- RabbitMQ (五) 交换规则