daily pastebin goal
57%
SHARE
TWEET

Untitled

ian Mar 20th, 2019 102 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import time
  2. import requests
  3. import configparser
  4. from selenium import webdriver
  5. from selenium.webdriver.common.by import By
  6. from selenium.webdriver.firefox.options import Options
  7. from selenium.webdriver.common.keys import Keys
  8. from selenium.webdriver.support.ui import WebDriverWait
  9. from selenium.webdriver.support import expected_conditions as EC
  10. from datetime import datetime
  11.  
  12. config = configparser.RawConfigParser()
  13. config.read("settings.ini")
  14.  
  15. ogusers_username = config.get("Settings", "ogusers_username")
  16. ogusers_password = config.get("Settings", "ogusers_password")
  17. post_delay = int(config.get("Settings", "post_delay"))
  18. sleep_time = int(config.get("Settings", "sleep_time"))
  19. API_KEY = config.get("Settings", "2captcha_api_key")
  20. headless = int(config.get("Settings", "headless"))
  21.  
  22. sleep_time_hours = round(sleep_time/60/60, 2)
  23.  
  24. options = Options()
  25. if headless < 1:
  26.     options.headless = False
  27. else:
  28.     options.headless = True
  29. browser = webdriver.Firefox(options=options)
  30. wait = WebDriverWait(browser,15)
  31.  
  32. browser.get("https://ogusers.com/member.php?action=login")
  33. try:
  34.     wait.until(EC.presence_of_element_located((By.XPATH, '//*[@id="fullcontainment"]/div[1]/form/table/tbody/tr[2]/td[2]/input')))
  35. except:
  36.     try:
  37.         solved = 0
  38.         while solved < 1:
  39.             print("Solving captcha, please wait...")
  40.             site_key = '6LfBixYUAAAAABhdHynFUIMA_sa4s-XsJvnjtgB0'  # site-key, read the 2captcha docs on how to get this
  41.             url = 'http://ogusers.com/'  # example url
  42.            
  43.             s = requests.Session()
  44.            
  45.             # here we post site key to 2captcha to get captcha ID (and we parse it here too)
  46.             captcha_id = s.post("http://2captcha.com/in.php?key={}&method=userrecaptcha&googlekey={}&pageurl={}".format(API_KEY, site_key, url)).text.split('|')[1]
  47.             # then we parse gresponse from 2captcha response
  48.             recaptcha_answer = s.get("http://2captcha.com/res.php?key={}&action=get&id={}".format(API_KEY, captcha_id)).text
  49.             while 'CAPCHA_NOT_READY' in recaptcha_answer:
  50.                 time.sleep(5)
  51.                 recaptcha_answer = s.get("http://2captcha.com/res.php?key={}&action=get&id={}".format(API_KEY, captcha_id)).text
  52.             recaptcha_answer = recaptcha_answer.split('|')[1]
  53.             browser.execute_script("document.getElementById('g-recaptcha-response').style.display = 'block';")
  54.             browser.execute_script("document.getElementById('recaptcha_submit').style.display = 'block';")
  55.             browser.find_element_by_xpath('//*[@id="g-recaptcha-response"]').send_keys(recaptcha_answer)
  56.             browser.switch_to.active_element.send_keys(Keys.TAB)
  57.             browser.switch_to.active_element.send_keys(Keys.RETURN)
  58.             time.sleep(3)
  59.             try:
  60.                 browser.get("https://ogusers.com/member.php?action=login")
  61.                 wait.until(EC.presence_of_element_located((By.XPATH, '//*[@id="fullcontainment"]/div[1]/form/table/tbody/tr[1]/td/span/strong')))
  62.                 print("Captcha solved.")
  63.                 solved = 1
  64.             except:
  65.                 print("Captcha solved incorrectly.")
  66.                 solved = 0
  67.                 browser.refresh()
  68.     except:
  69.         print("An unknown error has occured.")
  70.         sttime_3 = datetime.now().strftime('%Y_%m_%d_%H_%M_%S')
  71.         file_name_3 = "unknown_error_" + sttime_3 + ".png"
  72.         browser.save_screenshot(file_name_3)
  73.         print("Error screenshot saved as " + file_name_3 + ".")
  74.         browser.quit()
  75.         exit()
  76. print("Logging into OGUsers.")
  77. try:
  78.     browser.find_element_by_xpath('//*[@id="fullcontainment"]/div[1]/form/table/tbody/tr[2]/td[2]/input').send_keys(str(ogusers_username))
  79.     browser.find_element_by_xpath('//*[@id="fullcontainment"]/div[1]/form/table/tbody/tr[3]/td[2]/input').send_keys(str(ogusers_password))
  80.     browser.find_element_by_xpath('//*[@id="fullcontainment"]/div[1]/form/table/tbody/tr[5]/td/span/input').click()
  81.     wait.until(EC.presence_of_element_located((By.XPATH, '//*[@id="cat_1_e"]/tr[1]/td[2]/a')))
  82.     print("Successfully logged into OGUsers.")
  83. except:
  84.     print("There was an error logging into OGUsers.")
  85.     sttime = datetime.now().strftime('%Y_%m_%d_%H_%M_%S')
  86.     file_name = "login_error_" + sttime + ".png"
  87.     browser.save_screenshot(file_name)
  88.     print("Error screenshot saved as " + file_name + ".")
  89.     browser.quit()
  90.     exit()
  91.  
  92. if post_delay < 15:
  93.     print("WARNING: Post delays are recommended to be atleast 15 seconds.")
  94. if sleep_time_hours < 1:
  95.     print("WARNING: Auto-bump delays are recommended to be atleast 1 hour.")
  96.    
  97. print("Running a " + str(post_delay) + " second delay between posts.")
  98. print("Running a " + str(sleep_time_hours) + " hour delay between auto-bumps.")
  99.  
  100. while True:
  101.     try:
  102.         browser.get("https://ogusers.com/")
  103.         wait.until(EC.presence_of_element_located((By.XPATH, '//*[@id="cat_1_e"]/tr[2]/td[2]/a')))
  104.     except:
  105.         try:
  106.             solved = 0
  107.             while solved < 1:
  108.                 print("Solving captcha, please wait...")
  109.                 site_key = '6LfBixYUAAAAABhdHynFUIMA_sa4s-XsJvnjtgB0'  # site-key, read the 2captcha docs on how to get this
  110.                 url = 'http://ogusers.com/'  # example url
  111.                
  112.                 s = requests.Session()
  113.                
  114.                 # here we post site key to 2captcha to get captcha ID (and we parse it here too)
  115.                 captcha_id = s.post("http://2captcha.com/in.php?key={}&method=userrecaptcha&googlekey={}&pageurl={}".format(API_KEY, site_key, url)).text.split('|')[1]
  116.                 # then we parse gresponse from 2captcha response
  117.                 recaptcha_answer = s.get("http://2captcha.com/res.php?key={}&action=get&id={}".format(API_KEY, captcha_id)).text
  118.                 while 'CAPCHA_NOT_READY' in recaptcha_answer:
  119.                     time.sleep(5)
  120.                     recaptcha_answer = s.get("http://2captcha.com/res.php?key={}&action=get&id={}".format(API_KEY, captcha_id)).text
  121.                 recaptcha_answer = recaptcha_answer.split('|')[1]
  122.                 browser.execute_script("document.getElementById('g-recaptcha-response').style.display = 'block';")
  123.                 browser.execute_script("document.getElementById('recaptcha_submit').style.display = 'block';")
  124.                 browser.find_element_by_xpath('//*[@id="g-recaptcha-response"]').send_keys(recaptcha_answer)
  125.                 browser.switch_to.active_element.send_keys(Keys.TAB)
  126.                 browser.switch_to.active_element.send_keys(Keys.RETURN)
  127.                 time.sleep(3)
  128.                 try:
  129.                     browser.get("https://ogusers.com/")
  130.                     wait.until(EC.presence_of_element_located((By.XPATH, '//*[@id="cat_1_e"]/tr[2]/td[2]/a')))
  131.                     print("Captcha solved.")
  132.                     solved = 1
  133.                 except:
  134.                     print("Captcha solved incorrectly.")
  135.                     solved = 0
  136.                     browser.refresh()
  137.         except:
  138.             print("An unknown error has occured.")
  139.             sttime_3 = datetime.now().strftime('%Y_%m_%d_%H_%M_%S')
  140.             file_name_3 = "unknown_error_" + sttime_3 + ".png"
  141.             browser.save_screenshot(file_name_3)
  142.             print("Error screenshot saved as " + file_name_3 + ".")
  143.             browser.quit()
  144.             exit()
  145.     thread = 1
  146.     for line in open('threads.txt'):
  147.         if thread >= 10:
  148.             print("WARNING: Bumping over 10 threads an hour is not recommended, you risk getting warned or banned for spamming.")
  149.         print("Posting on thread number " + str(thread) + ".")
  150.         url = line.split(',')[0]
  151.         text = line.split(',')[1]
  152.         try:
  153.             browser.get(url)
  154.             browser.switch_to.active_element.send_keys(Keys.TAB)
  155.             browser.switch_to.active_element.send_keys(Keys.CONTROL + "a")
  156.             browser.switch_to.active_element.send_keys(str(text))
  157.             browser.find_element_by_xpath("//input[@value='Post Reply']").click()
  158.             print("Successfully posted to thread number " + str(thread) + ".")
  159.         except:
  160.             print("There was an error posting to thread number " + str(thread) + ".")
  161.             sttime_2 = datetime.now().strftime('%Y_%m_%d_%H_%M_%S')
  162.             file_name_2 = "post_error_" + sttime_2 + ".png"
  163.             browser.save_screenshot(file_name_2)
  164.             print("Error screenshot saved as " + file_name_2 + ".")
  165.         time.sleep(post_delay)
  166.         thread = thread + 1
  167.     print("Finished auto-bumping, sleeping for " + str(sleep_time_hours) + " hours. " + datetime.now().strftime('%H:%M'))
  168.     time.sleep(sleep_time)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top