from time import sleep
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from data import *
class SteamBot:
def _init_(self):
self.username = username
self.password = password
self.driver = webdriver.Chrome(executable_path=r'путь к хром драйверу')
def close_browser(self):
self.driver.close()
self.driver.quit()
def log_into_steam(self):
pass
def xpath_exists(self, xpath) -> bool:
try:
self.driver.find_element_by_xpath(xpath)
exist = True
except NoSuchElementException:
exist = False
return exist
def log_into_steam(self):
driver = self.driver
driver.get(steam_link)
driver.implicitly_wait(5)
driver.find_element('username').send_keys(username)
sleep(1)
driver.find_element('password').send_keys(password)
sleep(1)
driver.find_element_by_css_selector("button[type=submit]").click()
sleep(2)
self.type_steam_guard_code()
def type_steam_guard_code(self):
if self.xpath_exists("//input[@id = 'twofactorcode_entry']"):
code = input("Type your Steam Guard code: ")
self.driver.find_element_by_xpath("//input[@id='twofactorcode_entry']").sendkeys(code)
sleep(1)
self.driver.find_element_by_css_selector("div[type=submit]").click()
sleep(3)
else:
sleep(3)
bot = SteamBot()
if __name__ == "__main__":
bot.log_into_steam()
def log_into_steam(self):
pass