Files
2505140092 4fd18a730f 作业3
2026-03-19 19:36:41 +08:00

10 lines
337 B
Python

from bs4 import BeautifulSoup
soup = BeautifulSoup(html_content, 'lxml')
title = soup.find('title').string
print("页面标题:", title)
links = soup.find_all('a')
for link in links:
print("链接地址:", link.get('href'))
div_elements = soup.select('div.class_name')
for div in div_elements:
print("div内容:", div.grt_text())