数据提取¶
用于从页面提取信息的方法。
get_page_source()¶
返回页面的完整 HTML 字符串。
html = driver.get_page_source()
# 保存到文件
with open("page.html", "w", encoding="utf-8") as f:
f.write(html)
# 使用 BeautifulSoup 解析
from bs4 import BeautifulSoup
soup = BeautifulSoup(html, "html.parser")
BeautifulSoup 是可选的
cdriv 不依赖 BeautifulSoup。如需使用,请单独安装:pip install beautifulsoup4
get_title()¶
返回页面标题(<title> 标签的内容)。