Advertisement
Guest User

Untitled

a guest
Aug 19th, 2016
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.30 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2.  
  3. import os
  4. import random
  5. import string
  6. from selenium import webdriver
  7. from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
  8. from selenium.webdriver.support.ui import WebDriverWait
  9. from selenium.webdriver.common.by import By
  10. from selenium.webdriver.support import expected_conditions as EC
  11. from selenium.webdriver.common.proxy import Proxy, ProxyType
  12.  
  13. num_accs = 1
  14.  
  15. proxy_list = open("proxies.txt", "r").read().split("\n")
  16. user_agents = open("user_agents.txt", "r").read().split("\n")
  17.  
  18. print("START WORK, {0} for create!".format(str(num_accs)))
  19.  
  20.  
  21. def generate_random_str():
  22. count = random.randint(8, 12)
  23. val = ''.join(random.choice(
  24. string.ascii_letters + string.digits) for _ in range(count))
  25. return val
  26.  
  27.  
  28. def main():
  29. try:
  30. proxy_full = proxy_list.pop(0)
  31. if ";" in proxy_full:
  32. proxy = proxy_full.split(";")[0]
  33. userpass = proxy_full.split(";")[1]
  34. else:
  35. proxy = proxy_full
  36. userpass = ""
  37. proxytype = "http"
  38. print(userpass)
  39. print(proxytype)
  40. except:
  41. proxy = ""
  42. proxy_full = ""
  43.  
  44. useragent = random.choice([line for line in user_agents])
  45.  
  46. DesiredCapabilities.PHANTOMJS[
  47. "phantomjs.page.settings.userAgent"] = useragent
  48.  
  49. path = os.path.abspath(
  50. os.path.dirname(
  51. "__file__") + 'bin/chromedriver')
  52.  
  53. proxy = Proxy({
  54. 'proxyType': ProxyType.MANUAL,
  55. 'httpProxy': proxy,
  56. 'ftpProxy': proxy,
  57. 'sslProxy': proxy,
  58. 'noProxy': ''
  59. })
  60.  
  61. path = 'C:\chromedriver.exe'
  62.  
  63. driver = webdriver.Chrome(executable_path=path)
  64.  
  65.  
  66.  
  67. driver.delete_all_cookies()
  68.  
  69. driver.set_window_size(1248, 1024)
  70.  
  71. driver.get("https://www.instagram.com/")
  72.  
  73. try:
  74. WebDriverWait(driver, 90).until(
  75. EC.presence_of_element_located(
  76. (By.XPATH, '//input[@name="password"]')))
  77. except:
  78. driver.save_screenshot("open.png")
  79. raise Exception
  80.  
  81. email = generate_random_str() + "@yahoo.com"
  82.  
  83. driver.find_element(By.XPATH, '//input[@name="email"]').send_keys(email)
  84.  
  85. driver.find_element(
  86. By.XPATH, '//input[@name="fullName"]').send_keys(generate_random_str())
  87.  
  88. username = generate_random_str()
  89.  
  90. driver.find_element(
  91. By.XPATH, '//input[@name="username"]').send_keys(username)
  92.  
  93. password = generate_random_str()
  94.  
  95. driver.find_element(
  96. By.XPATH, '//input[@name="password"]').send_keys(password)
  97.  
  98. driver.find_element(
  99. By.XPATH, '//button[contains(text(), "Регистрация")]').click()
  100.  
  101. try:
  102. WebDriverWait(driver, 30).until(
  103. EC.presence_of_element_located(
  104. (By.XPATH,
  105. '//p[contains(text(), "Experience the best version")]')))
  106. except:
  107. print("ERROR! INSTAGRAM NOT APPROVE ACC!")
  108. driver.save_screenshot("not_approve.png")
  109. driver.quit()
  110. return "ERROR"
  111.  
  112. acc = username + ":" + password + "@" + proxy_full
  113.  
  114. with open("success_reg.txt", "a") as f1:
  115. f1.write(acc + "\n")
  116.  
  117. driver.exit()
  118.  
  119. print("SUCCESS REG!!")
  120.  
  121. count = 0
  122. while count <= num_accs:
  123. main()
  124. count += 1
  125.  
  126. print("Finish work!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement