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')

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