#导包import timeimport jsonfrom selenium import webdriverfrom seleniumwebdrivercommonkeys import Keys# 设置Chrome浏览器的选项以便在后台运行options = webdriverChromeOptionsoptionsadd_argumentheadlessoptionsadd_argument
可以在代码中修改Chrome浏览器的驱动路径,例如:
options = webdriver.ChromeOptions() options.add_argument('headless') options.add_argument('window-size=1920x1080') options.add_argument('disable-gpu') driver = webdriver.Chrome(executable_path='D:\chromedriver.exe', options=options)
注意要使用双斜杠来表示路径,或者使用单斜杠加r前缀表示原始字符串
另外,要确保chromedriver.exe文件存在于D盘的根目录下或者指定的路径下
原文地址: https://www.cveoy.top/t/topic/g63I 著作权归作者所有。请勿转载和采集!