windows下 python3.4.3 + selenium 3.0.b2 安装使用(一)

selenium的安装类似于Beautifulsoup,先附上 selenium3.0.1 下载地址 ,至于详细安装步骤

博主的 

python爬虫——windows + python3.4.3下的BeautifulSoup安装

   已有说明,要注意的一点,windows下解压tar.gz需要用可以解压 .7zip文件格式的压缩工具,比如好压,(winrar真是弱爆了)。


然后使用起来,真是醉醉的,测试代码如下:

import selenium

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

browser = webdriver.Firefox()
browser.get("http://www.baidu.com/")
browser.close()

一开始的报错是 找不到selenium模块,怎么也找不到,博主想是不是路径问题,试了很多都无解,结果第二天打开电脑,变了另一个错,如下:

>>> 
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\selenium-3.0.0b2-py3.4.egg\selenium\webdriver\common\service.py", line 64, in start
stdout=self.log_file, stderr=self.log_file)
File "C:\Python34\lib\subprocess.py", line 859, in __init__
restore_signals, start_new_session)
File "C:\Python34\lib\subprocess.py", line 1112, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] 系统找不到指定的文件。


During handling of the above exception, another exception occurred:


Traceback (most recent call last):
File "F:\爬虫\esuppliersindia\test.py", line 2, in <module>
driver = webdriver.Firefox()
File "C:\Python34\lib\site-packages\selenium-3.0.0b2-py3.4.egg\selenium\webdriver\firefox\webdriver.py", line 65, in __init__
self.service.start()
File "C:\Python34\lib\site-packages\selenium-3.0.0b2-py3.4.egg\selenium\webdriver\common\service.py", line 71, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH. 

百度解决链接,   知乎解决链接  

无外乎因为版本变化,需要加个驱动,先 是响应浏览器的 geckordiver下载 这是 火狐的 ,解压,配置到系统的path环境变量,然后一定要记得自己的.py放到geckordiver的同一大目录下,不然不行

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值