Pip install beautifulsoup4
Beautifulsoup4的安裝小測
演示HTML頁面地址:http://python123.io/ws/demo.html
Beautiful soup
From bs4 import BeautifulSoup
Soup=BeautifulSoup(“<html>data<html>”,”html.parser”)
#可以打開文件進行解析html 代碼
Soup2=BeautifulSoup(open(“D://demo.html”),”html.parser”)
獲得tag標籤的方法:
編譯器
源代碼 目標代碼