This commit is contained in:
2505140092
2026-03-19 19:36:41 +08:00
parent b5d1fb3aef
commit 4fd18a730f
4 changed files with 19 additions and 0 deletions

0
dxq01
View File

9
dxq01.py Normal file
View File

@@ -0,0 +1,9 @@
import requests
url = 'https://example.com'
params = {'key': 'value'}
response = requests.get(url, params=params)
if response.status_code == 200:
htm1_content = response.text
print("请求成功,获取到HTML内容")
else:
print(f"请求失败,状态码:{response.status_code}")

0
dxq02
View File

10
dxq02.py Normal file
View File

@@ -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.grt_text())