1 查看本地chrome 版本
chrome://version/
或者直接在本地路径中查看,见下图
2 按照版本号下载chromedriver,下载后复制到chrome本地路径下
chromedriver下载地址
3 将chrome 路径配置到系统path 变量下
4 打卡vscode
conda install selenium
5 .py文件测试,路径修改为自己的,我配置了chromedriver以后,运行终于不报错了。
from selenium import webdriver
chromedriver_path = r"C:\Users\AppData\Local\Google\Chrome\Application\chromedriver.exe"
driver = webdriver.Chrome(chromedriver_path)
# 登录百度
def main():
driver.get("https://baidu.com/")
if __name__ == '__main__':
main()