完成作业一:
This commit is contained in:
10
zsk.py
Normal file
10
zsk.py
Normal 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_element:
|
||||
print("div内容:", div.text)
|
||||
Reference in New Issue
Block a user