我的知识记录

Python 网页截图:批量给网页截图保存

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
 
def screenshot(url, output='screenshot.png'):
    options = Options()
    options.add_argument('--headless')
    options.add_argument('--window-size=1920,1080')
    driver = webdriver.Chrome(options=options)
    driver.get(url)
    driver.save_screenshot(output)
    driver.quit()
    print(f"已截图:{output}")
 
screenshot('https://www.baidu.com', 'baidu.png')

Python 网页截图:批量给网页截图保存

标签:

更新时间:2026-09-14 13:35:30

上一篇:Python 识别二维码内容:批量读取二维码

下一篇:Python 网页转 PDF:一键保存网页为 PDF