Advertisement
Guest User

Untitled

a guest
May 3rd, 2019
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.02 KB | None | 0 0
  1. from selenium import webdriver
  2. from selenium.common.exceptions import NoSuchElementException, TimeoutException
  3. from selenium.webdriver import ActionChains
  4. from selenium.webdriver.common.by import By
  5. from selenium.webdriver.common.keys import Keys
  6. from selenium.webdriver.common.proxy import Proxy, ProxyType
  7. from selenium.webdriver.support import expected_conditions as EC
  8. from selenium.webdriver.support.ui import WebDriverWait
  9.  
  10. import random
  11. import string
  12. import sys
  13. import time
  14.  
  15. proxies = []
  16. with open('proxies.txt') as f:
  17. proxies = f.readlines()
  18. print(proxies)
  19.  
  20. browser = webdriver.Chrome()
  21. action_chains = ActionChains(browser)
  22.  
  23. def get_new_proxy():
  24. global proxies
  25.  
  26. prox = Proxy()
  27. prox.proxy_type = ProxyType.MANUAL
  28. proxy_url = proxies.pop()
  29. prox.http_proxy = proxy_url
  30. prox.ssl_proxy = proxy_url
  31.  
  32. capabilities = webdriver.DesiredCapabilities.CHROME
  33. prox.add_to_capabilities(capabilities)
  34.  
  35. return webdriver.Chrome(desired_capabilities=capabilities)
  36.  
  37. def displayed():
  38. try:
  39. register_button1 = browser.find_element_by_xpath("//*[@id='react-root']/section/main/article/div[2]/div[1]/div/form/div[7]/div/button")
  40. if register_button1.is_displayed():
  41. hover6 = action_chains.move_to_element(register_button1).click_and_hold()
  42. hover6.perform()
  43. time.sleep(.05)
  44. release2 = action_chains.move_to_element(register_button1).release()
  45. release2.perform()
  46. time.sleep(7)
  47. displayed()
  48. except NoSuchElementException:
  49. pass
  50.  
  51. def instagram_2():
  52.  
  53. browser.get('https://www.instagram.com/jonbeloe/')
  54. time.sleep(random.randint(4,8))
  55.  
  56. follow_button = browser.find_element_by_xpath("//*[@id='react-root']/section/main/div/header/section/div[1]/span/span[1]/button")
  57. action_chains.move_to_element(follow_button)
  58. follow_button.click()
  59. time.sleep(random.randint(1,2))
  60.  
  61. profile_icon = browser.find_element_by_xpath("//*[@id='react-root']/section/nav/div[2]/div/div/div[3]/div/div[3]/a/span")
  62. action_chains.move_to_element(profile_icon)
  63. profile_icon.click()
  64. time.sleep(random.randint(1,2))
  65.  
  66. settings_icon = browser.find_element_by_xpath("//*[@id='react-root']/section/main/div/header/section/div[1]/div/button/span")
  67. action_chains.move_to_element(settings_icon)
  68. settings_icon.click()
  69. time.sleep(random.randint(1,2))
  70.  
  71. logout_button = browser.find_element_by_xpath("/html/body/div[3]/div/div/div/button[6]")
  72. action_chains.move_to_element(logout_button)
  73. logout_button.click()
  74. time.sleep(random.randint(1,2))
  75. print('account was made successfully')
  76.  
  77.  
  78.  
  79. def instagram():
  80. global browser
  81.  
  82. myList=(["a","b","c","d","e","f","g","h","i","j","f","k","z","d","e","f","g","h","i","j","f","k","z","d"])
  83. chars = (['1','2','3','4','5','6','7','8','9'])
  84. username = ''.join(random.choice(myList) for i in range(6))
  85. name = ''.join(random.choice(myList) for i in range(5))
  86. lastname = ''.join(random.choice(myList) for i in range(8))
  87. password12 = ''.join(random.choice(myList) for i in range(8)) + ''.join(random.choice(chars) for i in range (1))
  88. send_keys_username_box = username + ''.join(random.choice(chars) for i in range(3))
  89. email_chars = ''.join([random.choice(myList) for _ in range(10)] + [random.choice(chars) for _ in range(3)]) + '@gmail.com'
  90. send_keys_email_box = email_chars
  91.  
  92.  
  93. browser.maximize_window()
  94. browser.get('https://www.instagram.com/')
  95. time.sleep(random.randint(8,13))
  96.  
  97. random.shuffle(myList)
  98. random.shuffle(chars)
  99.  
  100. email_box = browser.find_element_by_xpath("//input[@name='emailOrPhone']")
  101. hover1 = action_chains.move_to_element(email_box)
  102. hover1.perform()
  103. time.sleep(random.randint(1,2))
  104. email_box.send_keys(send_keys_email_box)
  105. time.sleep(random.randint(2,3))
  106.  
  107. name_box = browser.find_element_by_xpath("//input[@name='fullName']")
  108. hover2 = action_chains.move_to_element(name_box)
  109. hover2.perform()
  110. time.sleep(random.randint(1,2))
  111. name_box.send_keys(name)
  112. time.sleep(random.randint(2,3))
  113.  
  114.  
  115. username_box = browser.find_element_by_xpath("//input[@name='username']")
  116. hover3 = action_chains.move_to_element(username_box)
  117. hover3.perform()
  118. time.sleep(random.randint(1,2))
  119. username_box.send_keys(send_keys_username_box)
  120. time.sleep(random.randint(2,3))
  121.  
  122. password_box = browser.find_element_by_xpath("//input[@name='password']")
  123. hover4 = action_chains.move_to_element(password_box)
  124. hover4.perform()
  125. time.sleep(random.randint(1,2))
  126. password_box.send_keys(password12)
  127. time.sleep(random.randint(1,2))
  128.  
  129. register_button = browser.find_element_by_xpath("//*[@id='react-root']/section/main/article/div[2]/div[1]/div/form/div[7]/div/button")
  130. action_chains.move_to_element(register_button).click_and_hold(register_button)
  131. # hover5.perform()
  132. time.sleep(.07)
  133. action_chains.move_to_element(register_button).release(register_button)
  134. # release1.perform()
  135. time.sleep(random.randint(5,7))
  136. displayed()
  137. visible_1()
  138.  
  139. def visible_1():
  140. time.sleep(12)
  141. global browser
  142. try:
  143. age_button = browser.find_element_by_xpath( "//input[@name='ageRadio' and @value='above_18']")
  144. if age_button.is_displayed():
  145. age_button = browser.find_element_by_xpath( "//input[@name='ageRadio' and @value='above_18']")
  146. action_chains.move_to_element(age_button)
  147. time.sleep(0.3)
  148. age_button.click()
  149.  
  150. time.sleep(2)
  151.  
  152. next_button = browser.find_element_by_xpath('//button[text()="Next"]')[1]
  153. action_chains.move_to_element(next_button)
  154. time.sleep(0.3)
  155. next_button.click()
  156. time.sleep(5)
  157. instagram_2()
  158. except NoSuchElementException:
  159. browser = visible_2(browser)
  160.  
  161.  
  162. def save_accounts():
  163. myList=(["a","b","c","d","e","f","g","h","i","j","f","k","z","d","e","f","g","h","i","j","f","k","z","d"])
  164. chars = (['1','2','3','4','5','6','7','8','9'])
  165. username = ''.join(random.choice(myList) for i in range(6))
  166. name = ''.join(random.choice(myList) for i in range(5))
  167. lastname = ''.join(random.choice(myList) for i in range(8))
  168. password12 = ''.join(random.choice(myList) for i in range(8)) + ''.join(random.choice(chars) for i in range (1))
  169. send_keys_username_box = username + ''.join(random.choice(chars) for i in range(3))
  170. email_chars = ''.join([random.choice(myList) for _ in range(10)] + [random.choice(chars) for _ in range(3)]) + '@gmail.com'
  171. send_keys_email_box = email_chars
  172. f = open('accounts.txt', 'a')
  173. f.write(f"sending password: {password12},email: {send_keys_email_box} and username: {send_keys_username_box} \n")
  174. print(f"sending password: {password12},email: {send_keys_email_box} and username: {send_keys_username_box} \n")
  175.  
  176. def visible_2(browser):
  177. try:
  178. proxy_not_working = browser.find_element_by_xpath("//*[@id='ssfErrorAlert']")
  179. if proxy_not_working.is_displayed():
  180. print("CAPTCHA")
  181. try:
  182. browser.quit()
  183. except:
  184. pass
  185.  
  186. browser = get_new_proxy()
  187.  
  188.  
  189. except NoSuchElementException:
  190. browser = visible_3(browser)
  191. return browser
  192.  
  193.  
  194.  
  195. def visible_3(browser):
  196. try:
  197. challenge = browser.find_element_by_xpath("//*[@id='phone_number']")
  198. if challenge.is_displayed():
  199. print("CAPTCHA")
  200. try:
  201. browser.quit()
  202. except:
  203. pass
  204.  
  205. browser = get_new_proxy()
  206.  
  207.  
  208. except NoSuchElementException:
  209. instagram_2()
  210. print('saving account info')
  211. save_accounts()
  212. time.sleep(5)
  213. return browser
  214.  
  215.  
  216.  
  217.  
  218.  
  219. # while True:
  220. # try:
  221. # instagram()
  222. # except NoSuchElementException as e:
  223. # print(e)
  224. # browser.quit()
  225. # browser = get_new_proxy()
  226.  
  227. while True:
  228. instagram()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement