From c80c20e0186556d86c13f0e70653a6335c263a2b Mon Sep 17 00:00:00 2001 From: 3575684936 <3575684936@student.edu.cn> Date: Thu, 19 Mar 2026 15:53:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xwl作业2.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 xwl作业2.py diff --git a/xwl作业2.py b/xwl作业2.py new file mode 100644 index 0000000..82081b7 --- /dev/null +++ b/xwl作业2.py @@ -0,0 +1,10 @@ +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.text) \ No newline at end of file