当前位置: 首页 > 知识库问答 >
问题:

运行selenium时获取NotADirectoryError

殷宾白
2023-03-14
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
from bs4 import BeautifulSoup

my_username = "username"
my_password = "pass"

driver = webdriver.Firefox()
driver.get("http://www.twitch.tv/user/login")
elem_user = driver.find_element_by_id("login_user_login")
elem_passwd = driver.find_element_by_id("user[password]")
elem_user.send_keys(my_username)
elem_passwd.send_keys(my_password + Keys.RETURN)
time.sleep(5)

html = driver.page_source
soup = BeautifulSoup(html)
logginTag = soup.find("a", {"id" : "user_display_name"})
print(logginTag)
driver.close()

error-driver=webdriver.firefox()文件“/users/grey/.pyenv/versions/3.7.3/lib/python3.7/site-packages/selenium/webdriver/firefox/webdriver/firefox/webdriver.py”,第164行,在init self.service.start()文件“/users/grey/.pyenv/versions/3.7.3/new_session”中,在init self.service.start()文件“文件”/users/grey/.pyenv/versions/3.7.3/lib/python3.7/subprocess.py“,第1522行,在_execute_child引发child_exception_type(errno_num,err_msg,err_filename)NotaDirectoryError:[errno20]不是目录:'geckodriver'

共有1个答案

李景天
2023-03-14

当你使用浏览器时,你需要驱动程序实例来交互,例如,如果你想使用chrome驱动程序,你需要chrome驱动程序exe;如果你想打开firefox,你需要gecko驱动程序

https://github.com/mozilla/geckodriver/releases您可以从此链接和安装路径下载最新的驱动程序,然后重新运行project

 类似资料: