马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("http://www.baidu.com")
各位大佬看看这个代码有问题吗,插件也下载了,但是运行后打不开浏览器,还报错。C:\Users\c\AppData\Local\Programs\Python\Python38-32\python.exe H:/系统默认/桌面/工作/Python工程/1.py
Traceback (most recent call last):
File "H:/系统默认/桌面/工作/Python工程/1.py", line 2, in <module>
driver = webdriver.Chrome()
File "C:\Users\c\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 76, in __init__
RemoteWebDriver.__init__(
File "C:\Users\c\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "C:\Users\c\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:\Users\c\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Users\c\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Failed to create Chrome process.
Process finished with exit code 1
应该是你没有添加那个插件的位置,这是我之前写的,用的edge,原理一样
driver_path = r'E:\python\edgedriver_win64\msedgedriver.exe'#浏览器路径
driver = webdriver.Edge(executable_path=driver_path)
driver.maximize_window()#最大化网页
driver.get("https://authserver.zjou.edu.cn/cas/login?service=http%3A%2F%2Fnewjwgl.zjou.edu.cn%2Feams%2Flogin.action")#打开指定网页
driver.refresh()#刷新屏幕
|