From fd0ea0e897b133c07fbdb82974685633ca96a310 Mon Sep 17 00:00:00 2001 From: 2509165004 <2509165004@student.edu.cn> Date: Thu, 19 Mar 2026 16:16:49 +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 --- lxj01.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 lxj01.py diff --git a/lxj01.py b/lxj01.py new file mode 100644 index 0000000..af96770 --- /dev/null +++ b/lxj01.py @@ -0,0 +1,13 @@ +from bs4 import BeautifulSoup +import requests +response = requests.get('https://example.com') +html_content = response.text +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