进行代码调试时:
from selenium import webdriver
c=webdriver.Chrome(executable_path=r'C:\Program Files\Google\Chrome\Application\chrome.exe') #获取chrome浏览器的驱动,并启动Chrome浏览器
c.get('https://www.baidu.com')#打开百度
print('成功')
出现错误信息:
在使用selenium爬取网页时遇到一个问题,只能启动Chrome浏览器,却无法加载指定URL。解决方法包括检查hosts文件中'127.0.0.1 localhost'的设置,确保其未被注释,以及验证localhost是否连通,如果防火墙导致问题,可能需要关闭防火墙。参考selenium的浏览器驱动问题解决方法。
进行代码调试时:
from selenium import webdriver
c=webdriver.Chrome(executable_path=r'C:\Program Files\Google\Chrome\Application\chrome.exe') #获取chrome浏览器的驱动,并启动Chrome浏览器
c.get('https://www.baidu.com')#打开百度
print('成功')
出现错误信息:
595
4181
1947
3771

被折叠的 条评论
为什么被折叠?