Loading... ``` from selenium import webdriver # 使用Selenium访问网页并截图 def take_screenshot(url, filename='screenshot.png'): # 设置浏览器选项,这里以Chrome为例 options = webdriver.ChromeOptions() options.add_argument('--headless') # 无头模式 # 创建WebDriver对象 with webdriver.Chrome(options=options) as driver: driver.get(url) # 打开网页 time.sleep(3) # 等待页面加载 driver.save_screenshot(filename) # 截图并保存 # 构建访问URL #url = f'http://{gateway_ip}' # 访问并截图 #take_screenshot(url, 'gateway_screenshot.png') ``` 最后修改:2024 年 05 月 11 日 © 允许规范转载 赞 如果觉得我的文章对你有用,请随意赞赏