记录使用selenium 遇到了的有过的报错
报错信息如下
> raise WebDriverException(f"Can not connect to the Service {self._path}")
E selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service /Users/XXXXX/.cache/selenium/chromedriver/mac-x64/120.0.6099.109/chromedriver
解决办法
120.0.6099.109的chrome 会自动下载对应版本的chromedriver,排除了版本问题。
搜索结果有说是hosts存在问题,接着查看hosts的:
vim etc/hosts
hosts缺少了localhost的相关配置
在hosts里加上 127.0.0.1 localhost ,如果注释掉了把注释打开就行,保存退出,重新运行代码就正常了。
127.0.0.1 localhost