我正在尝试保存网页的屏幕截图,为此我尝试使用 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 浏览器版本兼容。
感谢你们的帮助,实际上盖伊是对的,我必须指定端口:
options.add_argument('--remote-debugging-port=9222')
现在可以了!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)