import requests from bs4 import BeautifulSoup # 发送Http GET请求 response = requests.get("https://example.com") # 解析html响应 soup = BeautifulSoup(response.text, "html.parser") # 搜索特定的HTML元素 title = soup.find("title").text print(title)
登录后复制
import requests from bs4 import BeautifulSoup # 发送Http GET请求 response = requests.get("https://example.com") # 解析html响应 soup = BeautifulSoup(response.text, "html.parser") # 搜索特定的HTML元素 title = soup.find("title").text print(title)