[Python] 纯文本查看 复制代码 import pygame
from selenium import webdriver
import time
from selenium.webdriver.common.by import By
# 启动 Chrome 浏览器
driver = webdriver.Chrome()
# 打开本地静态网页
driver.get('本地静态页面地址')
# 等待一定时间
pygame.time.wait(5000)
# 获取页面数量
element = driver.find_element(By.ID, "maxPage")
page_count = int(element.text)
# 遍历每一页并截图
for i in range(1, page_count + 1):
# 等待页面加载完成
time.sleep(2)
# 点击下一页
if i > 1:
next_page_element = driver.find_element(By.CSS_SELECTOR, ".next-page")
next_page_element.click()
driver.save_screenshot(f'page_{i}.png')
# 截图保存为图片
driver.save_screenshot(f'page_{i}.png')
# 等待用户按下任意键退出
input("Press any key to exit...") |