Guest User

Untitled

a guest
Dec 11th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. import pickle
  2. import time
  3.  
  4. from selenium import webdriver
  5. from selenium.webdriver.common.by import By
  6. from selenium.webdriver.support import expected_conditions as EC
  7. from selenium.webdriver.support.ui import WebDriverWait
  8.  
  9. driver = webdriver.Firefox(executable_path='geckodriver.exe')
  10. driver.get('https://web.telegram.org')
  11. time.sleep(10)
  12.  
  13. WebDriverWait(driver, 20).until(
  14. EC.element_to_be_clickable((By.XPATH, '//input[contains(@name, "phone_country")]')))
  15. driver.find_element_by_xpath('//input[contains(@name, "phone_country")]').clear()
  16. driver.find_element_by_xpath('//input[contains(@name, "phone_country")]').send_keys('+%s' % '1')
  17. time.sleep(2)
  18. driver.find_element_by_xpath('//input[contains(@name, "phone_number")]').clear()
  19. time.sleep(2)
  20. number = input('Input number:')
  21. driver.find_element_by_xpath('//input[contains(@name, "phone_number")]').send_keys(number)
  22. time.sleep(2)
  23. WebDriverWait(driver, 20).until(
  24. EC.element_to_be_clickable((By.XPATH, '//div/a[contains(@class, "login_head_submit_btn")]')))
  25. driver.find_element_by_xpath('//div/a[contains(@class, "login_head_submit_btn")]').click()
  26. time.sleep(5)
  27. WebDriverWait(driver, 20).until(
  28. EC.element_to_be_clickable((By.XPATH, '//button[contains(@class, "btn btn-md btn-md-primary")]')))
  29. driver.find_element_by_xpath('//button[contains(@class, "btn btn-md btn-md-primary")]').click()
  30. time.sleep(5)
  31.  
  32. WebDriverWait(driver, 20).until(
  33. EC.element_to_be_clickable((By.XPATH, '//input[contains(@name, "phone_code")]')))
  34. driver.find_element_by_xpath('//input[contains(@name, "phone_code")]').clear()
  35.  
  36. code_telegram = input('Input code:')
  37.  
  38. time.sleep(5)
  39. driver.find_element_by_xpath('//input[contains(@name, "phone_code")]').send_keys(code_telegram)
  40. time.sleep(10)
  41.  
  42. pickle.dump(driver.get_cookies(), open("cookies.pkl", "wb"))
Add Comment
Please, Sign In to add comment