我正在尝试保存网页的截图,并试图使用Selenium实现。问题是,一旦打开网页,它就会保持空白,URL中会显示"data:"。
以下是我的代码:
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_experimental_option('useAutomationExtension', False)
driver = webdriver.Chrome(options=options,executable_path='aPath/chromedriver.exe',service_log_path='aPath/mylog.txt')
driver.get('http://myURL.html')
screenshot=driver.save_screenshot('aPath/my_screenshot.png')
driver.quit()
注意:我已经检查过我的ChromeDriver版本与我的Chrome浏览器版本兼容。
driver.get('http://myURL.html')
? - Guydriver.get('http://myURL.html')
这一行,它会无限期地停留在driver = webdriver.Chrome(options=options,e.....
这一行。 - Nefarious62