Advertisement
Guest User

Untitled

a guest
Apr 4th, 2020
402
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.43 KB | None | 0 0
  1. from selenium import webdriver
  2. from selenium.webdriver.common.keys import Keys
  3. from time import sleep
  4.  
  5. driver = webdriver.Chrome("C:\Program Files\chromedriver\chromedriver.exe")
  6. insta_link = "https://instagram.com"
  7. username = "123mihai456"
  8.  
  9. driver.get(insta_link)
  10.  
  11. def load_firends():
  12.     firends_file = open("friends.txt", "r")
  13.     firends_list = []
  14.     friends = firends_file.read()
  15.     return firends_list
  16.  
  17.  
  18. def NotNow():
  19.     try:
  20.         not_now_butt = driver.find_element_by_class_name("/html/body/div[1]/section/main/div/div/div/button")  #"sqdOP yWX7d    y3zKF     "
  21.         not_now_butt.click()
  22.     except:
  23.         print("Nu s-a gasit not now")
  24.  
  25.  
  26. def TurnOffNotifications():
  27.     try:
  28.         turn_off_button = driver.find_element_by_xpath("/html/body/div[4]/div/div/div[3]/button[2]")    #"aOOlW   HoLwm"
  29.         turn_off_button.click()
  30.     except:
  31.         print("nu s-a gasit notificare")
  32.  
  33.  
  34. # def find_verification_codes():
  35. #     driver.get('https://www.instagram.com/accounts/two_factor_authentication/')
  36. #     sleep(4)
  37. #     get_backup_codes = driver.find_element_by_xpath('//button[text()="Get Backup Codes"]')
  38. #     get_backup_codes.click()
  39. #     sleep(3)
  40. #     get_new_codes = driver.find_element_by_xpath('//button[text()="Get New Codes"]')
  41. #     get_new_codes.click()
  42. #     sleep(4)
  43. #     code = driver.find_element_by_xpath("/html/body/div[1]/section/main/div/article/div/ul/li[2]")
  44. #     code_file = open("code.txt", "w")
  45. #     code_file.write(str(code))
  46. #     code_file.close()
  47. #     #except:
  48. #         #"NU S-AU GASIT SETARILE!!!"
  49.  
  50. def get_code():
  51.     #code_file = open("code.txt", "r")
  52.     #return str(code_file.read())
  53.     return input("Introdu codul de autentificare: ")
  54.  
  55. def Login(username, pw):
  56.     sleep(2)
  57.     username_field = driver.find_element_by_name("username")
  58.     pw_field = driver.find_element_by_name("password")
  59.     username_field.send_keys(username)
  60.     pw_field.send_keys(pw)
  61.     driver.find_element_by_xpath("/html/body/div[1]/section/main/article/div[2]/div[1]/div/form/div[4]").click()
  62.     sleep(5)
  63.     code_field = driver.find_element_by_name("verificationCode")
  64.     code_field.send_keys(get_code())
  65.     sleep(1)
  66.     confirm_button = driver.find_element_by_xpath("/html/body/div[1]/section/main/div/article/div/div[1]/div/form/div[2]/button")
  67.     confirm_button.click()
  68.  
  69.  
  70. #Login(username, "M8fcpG8rTGTqd4hC")
  71. #sleep(8)
  72. #NotNow()
  73. #TurnOffNotifications()
  74. print(load_firends())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement