**1BeautifulSoup库的引用和标签含义**
<p class ="title">...</p>:
<p>...</p>:标签Tag,一般是成对出现的
class="title":属性Attributes,由0个或者多个键值对构成的
BeautifulSoup 常用的引用的方式:
from bs4 import BeautifulSoup
2BeautifulSoup的解析器
解析器 | 使用方法 | 条件 |
---|---|---|
bs4的HTML解析器 | BeautifulSoup(mk,‘html.praser’) | 安装bs4库 |
lxml的HTML解析器 | BeautifulSoup(mk,‘lxml’) | pip install lxml |
xml的HTML解析器 | BeautifulSoup(mk,‘xml’) | pip install xml |
html5lib的解析器 | BeautifulSoup(mk,‘html5lib’) | pip install html5lib |
3BeautifulSoup类的基本元素