{使用python自动处理无聊的内容}使用selenium / python进行网络抓取

时间:2019-06-20 14:25:28

标签: python-3.x selenium-webdriver environment-variables selenium-chromedriver selenium-firefoxdriver

我正在学习python。在使用Selenium进行Web抓取时,python显示chromedriver.exe / geckodriver.exe未添加到PATH的错误。但我已经将它们都添加到了路径中。

代码:

browser = webdriver.Chrome()

错误:

Traceback (most recent call last):
  File "C:\Users\HP\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\common\service.py", line 76, in start
    stdin=PIPE)
  File "C:\Users\HP\AppData\Local\Programs\Python\Python37-32\lib\subprocess.py", line 775, in __init__
    restore_signals, start_new_session)
  File "C:\Users\HP\AppData\Local\Programs\Python\Python37-32\lib\subprocess.py", line 1178, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<pyshell#8>", line 1, in <module>
    browser = webdriver.Chrome()
  File "C:\Users\HP\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__
    self.service.start()
  File "C:\Users\HP\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\common\service.py", line 83, in start
    os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

0 个答案:

没有答案