我真的很想用Python编程。
我想编写一个代码,在不同的断点(1280px / 768px / 320px)中打开一个URL,然后从网站上截取屏幕截图。
到目前为止,这是我的代码:
from selenium import webdriver
from pyvirtualdisplay import Display
import time
# Set Breakpoint for different View
Breakpoints = [1280, 768, 320]
"""
Open invisible Website in Breakpoint 1280
"""
display = Display(visible=0, size=(1280, 800))
display.start()
"""
Open the Headless Chrome Webdriver
"""
driver = webdriver.Chrome('/usr/local/bin/chromedriver')
driver.set_page_load_timeout(10)
driver.get('https://example.com')
driver.maximize_window()
"""
Take Screenshots and Save as File
"""
driver.get_screenshot_as_file('Screenshot_BrPt_1280.png')
time.sleep(1o)
driver.get_screenshot_as_file('Screenshot_BrPt_768.png')
time.sleep(1o)
driver.get_screenshot_as_file('Screenshot_BrPt_320.png')
我现在的问题是: 我如何重写这个代码,他循环通过不同的断点,在不同的断点中打开网站,并截取每个断点的截图?