完成作业一:Git入门

This commit is contained in:
2509165004
2026-03-19 16:16:49 +08:00
parent d999efb7cf
commit fd0ea0e897

13
lxj01.py Normal file
View File

@@ -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)