Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import chromedriver_autoinstaller
- from selenium import webdriver
- from selenium.webdriver.common.by import By
- from selenium.webdriver.support.ui import WebDriverWait
- from selenium.webdriver.support import expected_conditions as EC
- from selenium.common.exceptions import NoSuchElementException, TimeoutException
- import time
- import threading
- lock = threading.Lock()
- def get_key():
- response = requests.get("http://192.168.11.141/hot.php")
- return response.text.strip()
- def create_browser():
- chromedriver_autoinstaller.install()
- options = webdriver.ChromeOptions()
- options.add_argument("--no-sandbox")
- options.add_argument("--disable-dev-shm-usage")
- options.add_argument("--start-maximized")
- options.add_argument("--disable-infobars")
- options.add_argument("--disable-extensions")
- options.add_experimental_option("excludeSwitches", ["enable-automation"])
- options.add_argument("--proxy-server=192.168.11.69:8888")
- return webdriver.Chrome(options=options)
- def wait_for_xpath_and_click(browser, xpath, timeout=120):
- wait = WebDriverWait(browser, timeout)
- try:
- element = wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
- element.click()
- return True
- except TimeoutException:
- return False
- def check_button_active(browser, xpath):
- try:
- browser.find_element(By.XPATH, xpath + "[not(@disabled)]")
- return True
- except NoSuchElementException:
- return False
- def wait_for_optional_xpath_and_click(browser, xpath, timeout=10):
- wait = WebDriverWait(browser, timeout)
- try:
- element = wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
- element.click()
- return True
- except TimeoutException:
- return False
- def browser_task():
- browser = create_browser()
- while True:
- try:
- browser.get("https://tgapp.herewallet.app/auth/import")
- time.sleep(1)
- key = get_key()
- input_field_xpath = "//*[@id='root']/div/div[1]/label/textarea"
- browser.find_element(By.XPATH, input_field_xpath).send_keys(key)
- if not wait_for_xpath_and_click(browser, "//*[@id='root']/div/div[2]/button"):
- raise Exception("Button not found, restarting...")
- if wait_for_optional_xpath_and_click(browser, "//*[@id='root']/div/button", timeout=20):
- print("Optional button clicked")
- else:
- print("Optional button not found or not clickable")
- if not wait_for_xpath_and_click(browser, "//*[@id='root']/div/div/div/div[4]/div[1]"):
- raise Exception("Element not found, restarting...")
- next_button_xpath = "//*[@id='root']/div/div[2]/div/div[3]/div/div[2]/div[2]/button"
- if not check_button_active(browser, next_button_xpath):
- raise Exception("Button not active, restarting...")
- if not wait_for_xpath_and_click(browser, next_button_xpath):
- raise Exception("Next button not found or not clickable, restarting...")
- optional_button_xpath = "/html/body/div[3]/div/div[2]/div/div/div[2]/button"
- wait_for_optional_xpath_and_click(browser, optional_button_xpath)
- time.sleep(60)
- browser.delete_all_cookies()
- except Exception as e:
- print(e)
- browser.quit()
- browser = create_browser()
- def main():
- threads = []
- for _ in range(5): # Уменьшено количество потоков для снижения нагрузки
- t = threading.Thread(target=browser_task)
- t.start()
- threads.append(t)
- for t in threads:
- t.join()
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement