Я пытаюсь заставить этот python скрипт работать:
import json
import time
from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.remote import switch_to
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
def read_configuration_file():
with open('config.json') as file:
arguments = json.load(file)
return arguments
def login(driver, email, password):
driver.get('https://login.globo.com/login/1')
email_input = driver.find_element_by_name('login')
password_input = driver.find_element_by_name('password')
form = driver.find_element_by_id('login-form')
email_input.send_keys(email)
password_input.send_keys(password)
form.submit()
def click_on_target(driver, target):
driver.find_elements_by_class_name('inCORyOvohT4oJQIoKjlO')[target - 1].click()
def click_on_captcha(driver):
driver.find_element_by_class_name('gc__3_EfD').click()
arguments = read_configuration_file()
print("You're voting on", arguments['targetPosition'])
driver = webdriver.Edge(executable_path=arguments['webDriverPath'])
driver.implicitly_wait(8)
login(driver, arguments['credentials']['username'],
arguments['credentials']['password'])
driver.get(arguments['pollURL'])
correct_votes = 0
while True:
click_on_target(driver, arguments['targetPosition'])
click_on_captcha(driver)
time.sleep(5)
if not driver.find_element_by_class_name('_1iMqGq8UKv9W1nDF0AvZbu').is_displayed():
click_on_captcha(driver)
else:
correct_votes += 1
print(correct_votes, 'computed')
driver.get(arguments['pollURL'])
time.sleep(5)
driver.close()
JSON файл:
{
"pollURL": "",
"targetPosition": 1,
"credentials": {
"username": "",
"password": ""
},
"webDriverPath": "C:/Users/ticer/Documents/bbbvoter/msedgedriver.exe"
}
Но я продолжаю получать ту же ошибку:
("You're voting on", 1)
Traceback (most recent call last):
File "voter.py", line 41, in <module>
driver = webdriver.Edge(executable_path=arguments['webDriverPath'])
File "/home/tiberio/.local/lib/python2.7/site-packages/selenium/webdriver/edge/webdriver.py", line 56, in __init__
self.edge_service.start()
File "/home/tiberio/.local/lib/python2.7/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: 'msedgedriver.exe' executable needs to be in PATH. Please download from http://go.microsoft.com/fwlink/?LinkId=619687
Я скачал пограничный webdriver Версия: 82.0.459.1 x64, .exe находится в той же папке, что и скрипт, я не знаю, что еще сделать, чтобы он заработал, есть идеи? Что это значит, когда он говорит, что нуждается в PATH? спасибо:)