1、下载安装BeautifulSoup:
pip install BeautifulSoup
2、使用
import requests
r=requests.get("https://python123.io/ws/demo.html")
data=r.text
# 引入BeautifulSoup
from bs4 import BeautifulSoup
soup=BeautifulSoup(data,"html.parser") # html.parser :html解析器
printe(soup.prettify()) # prettify :美化器,每逢标签,自动换行
3、beautifulsoup解析器