From dc174b313e2a770bdef52bc503f544a532668c76 Mon Sep 17 00:00:00 2001 From: 2509165048 <2509165048@student.edu.cn> Date: Tue, 24 Mar 2026 23:00:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E4=BD=9C=E4=B8=9A=E4=B8=89?= =?UTF-8?q?=EF=BC=9A=E5=AE=8C=E6=88=90=E4=BD=9C=E4=B8=9A=E4=BA=8C=EF=BC=9A?= =?UTF-8?q?=E7=BD=91=E7=BB=9C=E6=95=B0=E6=8D=AE=E9=87=87=E9=9B=86=EF=BC=88?= =?UTF-8?q?=E7=88=AC=E8=99=AB=E5=9F=BA=E7=A1=80=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 2.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 2.py diff --git a/2.py b/2.py new file mode 100644 index 0000000..0695dbb --- /dev/null +++ b/2.py @@ -0,0 +1,27 @@ +import requests +from bs4 import BeautifulSoup as bs +print('------------') +url = 'https://www.baidu.com' +params = {'key':'value'} +response = requests.get(url,params=params) +print(response.status_code) +print('------------') +html_content = response.text +print(html_content) +print('------------') +soup = bs(html_content,'lxml') +print(soup) +print('============') +title = soup.find('title').string +print(title) +print('============') +links = soup.find_all('a') +print(links) +print('============') +for link in links: + # print("11111111") + print("链接:",link.get('href')) +div_element = soup.select('div.di') +print(div_element) +for div in div_element: + print('div:',div.text) \ No newline at end of file