From 6a89f53160be9b5f532fe17386502cb1fa0bd27d Mon Sep 17 00:00:00 2001 From: 2509165033 <2509165033@student.edu.cn> Date: Thu, 19 Mar 2026 16:07:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E4=BD=9C=E4=B8=9A=E4=B8=80?= =?UTF-8?q?=EF=BC=9AGit=E5=85=A5=E9=97=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 李佳豪.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/李佳豪.py b/李佳豪.py index 12c2dad..bda9be9 100644 --- a/李佳豪.py +++ b/李佳豪.py @@ -1,8 +1,10 @@ -import requests -url = 'http://example.com' -params = {'key':'value'} -response = requests.get(url, params=params) -if response.status_code == 200: - print("请求成功,获取到HTML内容") -else: - print(f"请求失败,状态码:{response.status_code}") \ No newline at end of file +from bs4 import BeautifulSoup +soup = BeautifulSoup(html_content, 'lxmx') +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