from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import os
Game_Pin = input('Enter your PIN: ')
NickNAME = input('Enter your nickname: ')
def Enter_Press():
browser.find_element_by_name("Enter").click()
def Kahoot_Spammer(Game_Pin, NickNAME):
chromedriver = webdriver.Chrome(r'C:WebDriverbinchromedriver_win32')
browser = webdriver.Chrome(chromedriver)
browser.get('https://kahoot.it/')
game_pin = browser.find_element_by_id("Game PIN")
Name = browser.find_element_by_id("Nickname")
game_pin.send_keys(Game_Pin)
Enter_Press()
Name.send_keys(NickNAME)
Enter_Press()
Kahoot_Spammer(Game_Pin, NickNAME)
想知道我在上面的代码中做错了什么。我放入路径并运行的文件
icacls "pathtochromedriver" /grant Users:F
命令通过命令提示符,但它仍然没有解决问题。我已经在这个问题上停留了一段时间了。
Traceback (most recent call last):
File "C:UsersovvipAppDataLocalProgramsPythonPython36-32libsite-packagesseleniumwebdrivercommonservice.py", line 76, in start
stdin=PIPE)
File "C:UsersovvipAppDataLocalProgramsPythonPython36-32libsubprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "C:UsersovvipAppDataLocalProgramsPythonPython36-32libsubprocess.py", line 997, in _execute_child
startupinfo)
PermissionError: [WinError 5] Access is denied
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:UsersovvipAppDataLocalProgramsPythonPython36-32KahootSpammer.py", line 28, in <module>
Kahoot_Spammer(Game_Pin, NickNAME)
File "C:UsersovvipAppDataLocalProgramsPythonPython36-32KahootSpammer.py", line 13, in Kahoot_Spammer
chromedriver = webdriver.Chrome(r'C:WebDriverbinchromedriver_win32')
File "C:UsersovvipAppDataLocalProgramsPythonPython36-32libsite-packagesseleniumwebdriverchromewebdriver.py", line 68, in __init__
self.service.start()
File "C:UsersovvipAppDataLocalProgramsPythonPython36-32libsite-packagesseleniumwebdrivercommonservice.py", line 88, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'chromedriver_win32' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home
关于如何解决这个问题的任何想法?每次我问这个问题时,我通常会得到一个答案,可以解决一件事,但随后会出现另一个问题。
尝试使用webdriver.Chrome(executable_path=r"C:WebDriverbinchromedriver_win32")
如果这不能解决问题,那么我认为您使用的chrome驱动程序版本可能存在问题 从此路径下载chromedriver
浏览器驱动程序下载链接
并将其粘贴到目录中
并为此代码对其进行测试,它应该运行顺利而没有任何错误
from selenium import webdriver
import selenium.webdriver.support.ui as ui
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.by import By
driver = webdriver.Chrome(executable_path=r"C:WebDriverbinchromedriver.exe")
for j in range(2,8):
for i in range(2,8):
driver.get('https://www.olx.com.pk/lahore/apple/q-iphone-6s/?search%5Bfilter_float_price%3Afrom%5D=40000&search%5Bfilter_float_price%3Ato%5D=55000')
str1 = '//*[@id="offers_table"]/tbody/tr['
str2 = ']/td/table/tbody/tr[1]/td[2]/h3/a/span'
str3 = str1 + str(i) + str2
a = driver.find_element_by_xpath(str3).text
print a
如果您遇到任何问题,请在下面发表评论
一方面:
chromedriver = webdriver.Chrome(r'C:WebDriverbinchromedriver_win32')
browser = webdriver.Chrome(chromedriver)
^^ 在此处创建一个名为chromedriver
的webdriver.Chrome
实例。 然后在下一行,您尝试创建另一个webdriver.Chrome
实例...但是这次将现有实例传递给它? 不知道为什么你试图创建它的多个实例,但该代码绝对不起作用。 只需创建单个webdriver.Chrome
实例并使用它:
browser = webdriver.Chrome(r'C:WebDriverbinchromedriver_win32')