打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH
【Python处理】
1. 零基础:
如果从来没有装过Selenium,直接执行。
pip install selenium  
2. 升级安装:
如果之前是Selenium2的用户,执行升级安装。
pip install --upgrade selenium   
【浏览器驱动】
1. 下载:
FireFox的驱动,gechodriver(蜥蜴驱动?!),找如下链接里面对应操作系统的:
https://github.com/mozilla/geckodriver/releases  
IE的驱动,edge(边界?!),找如下链接里面的Download:
https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/  
Chrome驱动,比较朴素地依旧命名为chromedriver:
https://sites.google.com/a/chromium.org/chromedriver/
其它的驱动,参考官网,能想到的驱动都在这里了。
http://www.seleniumhq.org/download/ 
2. 配置:
直接将下载的chromedriver.exe路径加到
driver = webdriver.Chrome(r"E:\Tools\Python\seleniumDriver\chromedriver.exe")
或者直接改变环境变量
import osos.environ["webdriver.chrome.driver"] = "E:\Tools\Python\seleniumDriver\chromedriver.exe"
【Python3+Selenium】
举个简单的例子
import timefrom selenium import webdriverdriver = webdriver.Chrome(r"E:\Tools\Python\seleniumDriver\chromedriver.exe")driver.get("http://www.baidu.com")print(driver.title)time.sleep(5)driver.quit()
或者这种修改环境变量的路径也可以:
import timefrom selenium import webdriverimport osos.environ["webdriver.chrome.driver"] = "C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe"driver = webdriver.Chrome()url = 'http://www.baidu.com'driver.get(url)print(driver.title)time.sleep(5)driver.quit()


来源:http://blog.csdn.net/zhangqilong120/article/details/70810046

---------------------------------------------------------------------------------
来源:http://blog.csdn.net/972301/article/details/62238451
火狐的方式成功了

配置:

以FireFox的驱动 geckodriver为例。下载后,建议可以直接放在FireFox的默认安装目录(C:\Program Files (x86)\Mozilla Firefox\)。

最重要一点:系统环境变量PATH里,添加上FireFox的安装路径。

然后,一切照旧运行。

Python+Selenium3

import time  from selenium import webdriver    driver = webdriver.Firefox()  driver.get("http://www.baidu.com")    driver.find_element_by_id("kw").clear()  driver.find_element_by_id("kw").send_keys("Python")  driver.find_element_by_id("su").click()  time.sleep(5)  driver.quit()  

 












本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Python使用浏览器模拟访问页面之使用ip代理
Selenium WebDriver 环境搭建和错误调试_chromedriver_win32必须下载否则无法测试chrome
Python Selenium示例 - 启动不同浏览器
用Python Selenium完成Chrome的自动化操作详解
在Python Selenium中为Chrome和Firefox浏览器开启headless模式 | 李辉的个人网站
Python Selenium中级篇之4
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服