Advertisement
Guest User

Untitled

a guest
Dec 16th, 2017
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.23 KB | None | 0 0
  1. def main(instance, proxy):
  2.     url = "http://www.adidas.co.uk/yeezy"
  3.     #url = "https://www.yzylab.com/yeezy"
  4.     #url = "https://atcproxys.com/splash-page/"
  5.     #url = "https://www.google.com/recaptcha/api2/demo"
  6.     url = "http://www.adidas.ru/yeezy"
  7.  
  8.     while True:
  9.         #Random staggered start to help your computer
  10.         x = float(random.randint(1*100, 20*100))/100
  11.         print "[#" + str(instance) + "]: will start in " + str(x) + " seconds using proxy: " + str(proxy) + "."
  12.         time.sleep(x)
  13.  
  14.        
  15.         print "[#" + str(instance) + "]: is starting."
  16.  
  17.         #All chrome driver dependencies
  18.         driver_path = r"C:\Program Files (x86)\Google\Chrome\chromedriver.exe"
  19.         chrome_options = webdriver.ChromeOptions()
  20.         chrome_options.add_argument("disable-infobars")
  21.         chrome_options.add_argument("--window-size=800,600")
  22.         #chrome_options.add_argument("--window-position=-3000,0")
  23.         #chrome_options.add_argument('--proxy-server=%s' % proxy)
  24.        
  25.         driver = webdriver.Chrome(executable_path=driver_path, chrome_options=chrome_options)
  26.         driver.get(url)
  27.        
  28.         print "[#" + str(instance) + "]: has loaded the splash page."
  29.        
  30.         #script = 'document.styleSheets[0].insertRule("body {color: red !important;}", 0 )'
  31.         #driver.execute_script(script)
  32.  
  33.  
  34.         #IF WE HAVE A CAPTCHA THEN THIS IS WHERE WE WILL SOLVE IT.
  35.         #captcha_solve(driver,instance,url,proxy)
  36.  
  37.  
  38.  
  39.  
  40.         #Checks the page every 30 seconds for 5 minutes to see if pass has been passed.
  41.         tries = 1
  42.         while True:
  43.             print "[#" + str(instance) + "]: is checking if splash has been passed for the: " + str(tries) + " time."
  44.  
  45.             html = driver.execute_script("return document.getElementsByTagName('html')[0].innerHTML")
  46.             check = "DO NOT REFRESH"
  47.             check2 = "ERROR"
  48.  
  49.             if check not in html:
  50.                 print "[#" + str(instance) + "]: has had an error."
  51.                 print "[#" + str(instance) + "]:"
  52.                 print "[#" + str(instance) + "]:"
  53.                 print "[#" + str(instance) + "]:"
  54.                 print "[#" + str(instance) + "]:"
  55.                 driver.set_window_position(1000, 100)
  56.                 if check2 not in html:
  57.                     print "[#" + str(instance) + "]: has possibly passed splash. Opening browser and writing cookies to file."
  58.                     print "[#" + str(instance) + "]:"
  59.                     print "[#" + str(instance) + "]:"
  60.                     print "[#" + str(instance) + "]:"
  61.                     print "[#" + str(instance) + "]:"
  62.                     driver.set_window_position(2000, 200)
  63.  
  64.                     #Save the cookies to a file incase there contains cookies for future splash bypasses.
  65.                     pickle.dump(driver.get_cookies() , open(str(int(time.time())) + "-" + str(proxy.replace(":","-")) + '.pkl',"wb"))
  66.  
  67.                     time.sleep(10000)
  68.             else:
  69.                 tries +=1
  70.                 time.sleep(30)
  71.  
  72.  
  73.             if tries > 50000:
  74.                 print "[#" + str(instance) + "]: is closing and will restart soon."
  75.                 driver.quit()
  76.                 time.sleep(20)
  77.                 break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement