跪求爬虫大神答疑:
本来下载了个chromedriver想做爬虫用,奈何连一个初级阶段的测试都出现问题。
代码如下:from selenium import webdriver browser=webdriver.Chrome() browser.get('www.baidu.com')
错误如下:`Traceback (most recent call last):
File “D:\Python\lib\site-packages\selenium\webdriver\common\service.py”, line 76, in start
stdin=PIPE)
File “D:\Python\lib\subprocess.py”, line 722, in init
errread, errwrite) = self._get_handles(stdin, stdout, stderr)
File “D:\Python\lib\subprocess.py”, line 1046, in _get_handles
c2pwrite = msvcrt.get_osfhandle(self._get_devnull())
File “D:\Python\lib\subprocess.py”, line 861, in _get_devnull
self._devnull = os.open(os.devnull, os.O_RDWR)
FileNotFoundError: [Errno 2] No such file or directory: ‘nul’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “D:\编程文件夹\爬虫\动态渲染页面爬取\chromedriver测试.py”, line 2, in
browser=webdriver.Chrome()
File “D:\Python\lib\site-packages\selenium\webdriver\chrome\webdriver.py”, line 73, in init
self.service.start()
File “D:\Python\lib\site-packages\selenium\webdriver\common\service.py”, line 83, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: ‘chromedriver’ executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

试过了网上所有关于解决办法,包括将chromedriver.exe放到python中的scripts文件夹中,包括在Chrome()方法中声明路径,都是弹出这个错误。环境变量配置貌似也没问题。
关于chromedriver的问题,跪求爬虫大神解答
`但是有一个细节,就是在运行代码的时候,windows防火墙组织了python调用某些程序,我按允许,不知道有没有关系。
希望能有大佬帮助解决这个让我绞尽脑子的问题

相关文章: