首页 > 解决方案 > 如何解决这个 selenium-chromedriver 错误?

问题描述

我做了一个代码


from bs4 import BeautifulSoup
from selenium import webdriver
from urllib.request import urlopen
from urllib.parse import quote_plus
import time


url1 = "https://www.instagram.com/explore/tags/"
url2 = input("write a hashtag : ")
url = url1 + quote_plus(url2)


driver = webdriver.Chrome('executable_path=r"C:\Chrome\chromedriver.exe"')
driver.get(url)

我收到一条错误消息

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/selenium/webdriver/common/service.py", line 72, in start
    self.process = subprocess.Popen(cmd, env=self.env,
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 947, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 1819, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'chromedriver'

我已经安装了 chromedriver 并想知道如何使新的 chrome 页面出现任何评论将不胜感激

标签: pythonseleniumselenium-webdriverselenium-chromedriver

解决方案


推荐阅读