【发布时间】:2018-11-26 03:46:40
【问题描述】:
所以我一直在尝试按照这个 YouTube 教程 (https://www.youtube.com/watch?v=BGU2X5lrz9M) 作为一个快速有趣的项目来向自己介绍 selenium,但我已经遇到了问题。每当我运行我的代码时,我都会收到此错误:“chromedriver”可执行文件需要在 PATH 中。我已经多次搜索问题,将 chromedriver.exe 移动到 C:/ 目录以使事情变得更容易,并且尽我所能使用环境变量,但仍然无法解决这个问题。请帮帮我! 这是我正在运行的代码
# This bot is made following this YouTube tutorial: https://www.youtube.com/watch?v=BGU2X5lrz9M
# All the import crap
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
driver = webdriver.Chrome("C:\\chromedriver.exe")
class InstaBot:
def __init__(self, username, password):
self.username = username
self.password = password
self.driver = webdriver.Chrome()
def close_browser(self):
self.driver.close()
def login(self):
global driver
driver = self.driver
driver.get("https://www.instagram.com/accounts/login/?source=auth_switcher")
time.sleep(2)
# "//a[@href'accounts/login']"
# "//input[@name='username']"
# "//input[@name='password']"
georgeIG = InstaBot("NotGonnaShowToStackOverflow", "NotGonnaShowToStackOverflow")
georgeIG.login()
【问题讨论】:
标签: python selenium path selenium-chromedriver