BeautifulSoup入门001

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解析器

发布了39 篇原创文章 · 获赞 6 · 访问量 2015

猜你喜欢

转载自blog.csdn.net/weixin_45493345/article/details/102631642