from bs4 import BeautifulSoupimport rewith open='open'('index.html', 'r', encoding='utf8') as file: content = file.read()soup = BeautifulSoup(content, 'html.parser')title = soup.title.stringprint("网页标题:", title)h1 = soup.find('h1')print("一级标题:", h1.text)p = soup.find_all('p')[0] # 获取第一个段落标签print("段落内(nei)容(rong):", p.text)