Python网络爬虫:Beautiful Soup库入门

Beautiful Soup库安装
pip install beautifulsoup4测试:
import requestsr = requests.get("http://Python123.io/ws/demo.html")demo = r.textform bs4 import BeautifulSoup #从bs4中引入BeautifulSoup类soup = BeautifulSoup(demo, "html.parser")

Python网络爬虫:Beautiful Soup库入门

文章插图
 
Beautiful Soup库是解析、遍历、维护“标签树”的功能库
【Python网络爬虫:Beautiful Soup库入门】Beautiful Soup库的基本元素
Beautiful Soup库的引用
Beautiful Soup库 , 也叫beautifulsoup4或bs4.
from bs4 import BeautifulSoupsoup = BeautifulSoup(demo,"html.parser")


    推荐阅读