# pip install requests # pip install beautifulsoup4 import requests from bs4 import BeautifulSoup # 要爬取的网页 URL url = "https://yuncode.net/list/python" # 发送 HTTP GET 请求,并获取响应内容 response = requests.get(url) # 使用 BeautifulSoup 解析 HTML 内容 soup = BeautifulSoup(response.text, "html.parser") # 打印出网页的标题 print(soup.title.string) # 打印出网页中所有的链接 for link in soup.find_all("a"): print(link.get("href"))