Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pickle
- import time
- from selenium import webdriver
- from selenium.webdriver.common.by import By
- from selenium.webdriver.support import expected_conditions as EC
- from selenium.webdriver.support.ui import WebDriverWait
- driver = webdriver.Firefox(executable_path='geckodriver.exe')
- driver.get('https://web.telegram.org')
- time.sleep(10)
- WebDriverWait(driver, 20).until(
- EC.element_to_be_clickable((By.XPATH, '//input[contains(@name, "phone_country")]')))
- driver.find_element_by_xpath('//input[contains(@name, "phone_country")]').clear()
- driver.find_element_by_xpath('//input[contains(@name, "phone_country")]').send_keys('+%s' % '1')
- time.sleep(2)
- driver.find_element_by_xpath('//input[contains(@name, "phone_number")]').clear()
- time.sleep(2)
- number = input('Input number:')
- driver.find_element_by_xpath('//input[contains(@name, "phone_number")]').send_keys(number)
- time.sleep(2)
- WebDriverWait(driver, 20).until(
- EC.element_to_be_clickable((By.XPATH, '//div/a[contains(@class, "login_head_submit_btn")]')))
- driver.find_element_by_xpath('//div/a[contains(@class, "login_head_submit_btn")]').click()
- time.sleep(5)
- WebDriverWait(driver, 20).until(
- EC.element_to_be_clickable((By.XPATH, '//button[contains(@class, "btn btn-md btn-md-primary")]')))
- driver.find_element_by_xpath('//button[contains(@class, "btn btn-md btn-md-primary")]').click()
- time.sleep(5)
- WebDriverWait(driver, 20).until(
- EC.element_to_be_clickable((By.XPATH, '//input[contains(@name, "phone_code")]')))
- driver.find_element_by_xpath('//input[contains(@name, "phone_code")]').clear()
- code_telegram = input('Input code:')
- time.sleep(5)
- driver.find_element_by_xpath('//input[contains(@name, "phone_code")]').send_keys(code_telegram)
- time.sleep(10)
- pickle.dump(driver.get_cookies(), open("cookies.pkl", "wb"))
Add Comment
Please, Sign In to add comment