NotADirectoryError: [WinError 267] 目录名称无效。: ‘E:\\driver\\geckodriver.exe‘

今天做爬虫的时候,在IDLE上面要使用火狐浏览器驱动器时候,反复出现下面错误:
Traceback (most recent call last):
File “<pyshell#9>”, line 1, in
driver=webdriver.Firefox(r’E:\driver\geckodriver.exe’)
File “C:\Users\lenovo\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\selenium\webdriver\firefox\webdriver.py”, line 151, in init
firefox_profile = FirefoxProfile(firefox_profile)
File “C:\Users\lenovo\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\selenium\webdriver\firefox\firefox_profile.py”, line 79, in init
shutil.copytree(self.profile_dir, newprof,
File “C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1520.0_x64__qbz5n2kfra8p0\lib\shutil.py”, line 552, in copytree
with os.scandir(src) as itr:
NotADirectoryError: [WinError 267] 目录名称无效。: ‘E:\\driver\\geckodriver.exe’

火狐版本过高了,直接用webdriver去启动已经不行了,需要加上两个参数:

driverpath='E:\driver\geckodriver.exe'    //驱动器的位置
driver=webdriver.Firefox(executable_path=driverpath,service_log_path=r"E:\\driver\\watchlog.log")  //第一个参数为配置执行路径,第二个必须加上为产生的日志文件和位置

直接在IDLE上就可以启动火狐了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值