daily pastebin goal
70%
SHARE
TWEET

Untitled

a guest Mar 16th, 2018 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import time, sys
  2. import config as cfg
  3. from selenium import webdriver
  4. from selenium.common.exceptions import NoSuchElementException, StaleElementReferenceException
  5. from selenium.webdriver.common.keys import Keys
  6. from pymongo import MongoClient
  7. from bson.objectid import ObjectId
  8. from random import randint, choice
  9.    
  10. import time, sys
  11. import config as cfg
  12. from selenium import webdriver
  13. from selenium.common.exceptions import NoSuchElementException, StaleElementReferenceException
  14. from selenium.webdriver.common.keys import Keys
  15. from pymongo import MongoClient
  16. from bson.objectid import ObjectId
  17. from random import randint, choice
  18.  
  19. username = sys.argv[1]
  20. password = sys.argv[2]
  21.  
  22. def main():
  23.     driverPath = cfg.app['driverPath']
  24.     dataPath = './profile/'+username
  25.  
  26.     options = webdriver.ChromeOptions()
  27.     options.add_argument("--user-data-dir=" + dataPath)
  28.     if cfg.app['headless']:
  29.         options.add_argument('headless')
  30.  
  31.     if cfg.app['no-sandbox']:
  32.         options.add_argument('no-sandbox')
  33.  
  34.     options.add_argument(
  35.         'user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 Safari/537.36')
  36.     driver = webdriver.Chrome(chrome_options=options, executable_path=driverPath)
  37.  
  38.     webpage = "https://someweb.domain"
  39.     driver.get(webpage)
  40.  
  41.     # humanize a thing
  42.     time.sleep(randint(3, 10))
  43.  
  44.     username_form = driver.find_elements_by_css_selector('input.username"][type="text"]')
  45.     if len(username_form) > 0:
  46.         password_form = driver.find_element_by_css_selector('input[type="password"]')
  47.         submit_btn = driver.find_element_by_css_selector('form[method="post"]')
  48.  
  49.         username_form.send_keys(username)
  50.         password_form.send_keys(password)
  51.         submit_btn.submit()
  52.         time.sleep(randint(4,10)) # randSLOWare ?
  53.  
  54.     time.sleep(randint(3,9))
  55.  
  56.     queue = mongo("queue")
  57.     while True:
  58.         status = queue.find({"username": username, "status": "queued"}).sort([("_id", 1)])
  59.         for post in status:
  60.             check_next = is_next(post["_id"])
  61.             if check_next == "cuss":
  62.                 tacko = get_tacko(str(post["client"]).split("<@!@>"))
  63.                 status_box = driver.find_element_by_css_selector("main textarea")
  64.                 status_box.send_keys(tacko)
  65.  
  66.                 give_tacko = driver.find_element_by_css_selector('div[role="button"] > div')
  67.                 give_tacko.click()
  68.                 total_plus(post["_id"], tacko)
  69.                 time.sleep(3)
  70.             elif check_next == "kelar":
  71.                 post["status"] = "success"
  72.                 queue.update({"_id": ObjectId(str(post["_id"]))}, post)
  73.  
  74.             ''' HUMANIZE A THING '''
  75.             time.sleep(randint(7, 16))
  76.             driver.get(webpage)
  77.             time.sleep(randint(8,13))
  78.  
  79. def mongo(col):
  80.     client = MongoClient("mongodb://127.0.0.1/27017")
  81.     db = client["mydb"]
  82.     col = db[col]
  83.     return col
  84.  
  85. def get_tacko(arr):
  86.     return str(choice(arr))
  87.  
  88. def total_plus(queue_id, tacko):
  89.     queue = mongo("queue")
  90.     check = queue.find_one({"_id": ObjectId(str(queue_id))})
  91.     if check:
  92.         current_total = int(str(check["total"]))
  93.         current_total += 1
  94.         ltacko = str(check["tacko"]).split("<@!@>")
  95.         ltacko.remove(tacko)
  96.         tackos = "<@!@>".join(ltacko)
  97.         check["total"] = current_total
  98.         check["latest_post"] = int(time.strftime("%Y%m%d%H%M"))
  99.         check["tackos"] = tackos
  100.         queue.update({"_id": ObjectId(str(queue_id))}, check)
  101.  
  102. def is_next(queue_id):
  103.     queue = mongo("queue")
  104.     check = queue.find_one({"_id": ObjectId(str(queue_id))})
  105.     if check:
  106.         # already stored as integer in mongodb
  107.         total_times = int(check["total_post"])
  108.         total_now = int(check["total"])
  109.         tacko_every = int(check["tacko_every"])
  110.         latest_tacko = int(check["latest_tacko"])
  111.         if total_now < total_times:
  112.             now = int(time.strftime("%Y%m%d%H%M"))
  113.             cout = now - latest_tacko
  114.             if cout >= tacko_every:
  115.                 return "cuss" # continue
  116.             else:
  117.                 return "sabar" # please wait
  118.         else:
  119.             return "kelar" # done, change to "success"
  120.     else:
  121.         return "gada"
  122.  
  123. if __name__ == '__main__':
  124.     main()
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