python selenium webdriver启动chrome浏览器的方法

不废话,直接进入主题,本次演示如何启动chrome,且指定默认的profile


下载chromedriver


地址:http://chromedriver.storage.googleapis.com/index.html?path=2.33/


特别注意:看notes.txt注意版本号一定要匹配啊,如果chromedriver版本和你的chrome版本不匹配那就可能启动不了!!!!!


实战代码


from selenium import webdriver

path="chromedriver.exe所在的完整路径"
option=webdriver.ChromeOptions()

#用chrome地址栏输入chrome://version/,查看自己的【个人资料路径】
option.add_argument('--user-data-dir=上面查看的个人资料路径写这里')
driver=webdriver.Chrome(executable_path=path,chrome_options=option)

#return driver