代碼如下:
from selenium import webdriver
brower = webdriver.Firefox()
brower.get('https://www.taobao.com')
print(brower.page_source)
brower.close()
運行結果:
Traceback (most recent call last):
File "/home/eric/.local/lib/python3.5/site-packages/selenium/webdriver/common/service.py", line 74, in start
stdout=self.log_file, stderr=self.log_file)
File "/usr/lib/python3.5/subprocess.py", line 947, in init
restore_signals, start_new_session)
File "/usr/lib/python3.5/subprocess.py", line 1551, in _execute_child
raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'geckodriver'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/eric/PycharmProjects/untitled12/12.py", line 2, in
brower = webdriver.Firefox()
File "/home/eric/.local/lib/python3.5/site-packages/selenium/webdriver/firefox/webdriver.py", line 144, in init
self.service.start()
File "/home/eric/.local/lib/python3.5/site-packages/selenium/webdriver/common/service.py", line 81, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
Process finished with exit code 1
FileNotFoundError: [Errno 2] No such file or directory: 'geckodriver'
http://blog.csdn.net/zhuchen233/article/details/53398234
没有驱动,下载一个火狐驱动,具体步骤如下
没有驱动,下载一个火狐驱动,火狐驱动下载地址具体步骤如下 在环境变量 path 中添加D:\Program Files (x86)\Mozilla Firefox; 火狐浏览器的安装位置,最后将驱动放置在python的安装目录下,具体如图
謝謝,問題已經解決