抱歉,您的浏览器无法访问本站
本页面需要浏览器支持(启用)JavaScript
了解详情 >

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import requests
from bs4 import BeautifulSoup #引入BeautifulSoup类

url = "https://python123.io/ws/demo.html"

r = requests.get(url)

print(r.status_code)

print("\n")

#demo = r.text #html格式信息

#soup = BeautifulSoup(demo,"html.parser")#使用html.parser对demo进行html解析
soup = BeautifulSoup(open(r"C:\Users\Administrator\Desktop\beautifulsoup\demo.html"))
print(soup.prettify())

BeautifulSoup官方文档