Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time, sys
- import config as cfg
- from selenium import webdriver
- from selenium.common.exceptions import NoSuchElementException, StaleElementReferenceException
- from selenium.webdriver.common.keys import Keys
- from pymongo import MongoClient
- from bson.objectid import ObjectId
- from random import randint, choice
- import time, sys
- import config as cfg
- from selenium import webdriver
- from selenium.common.exceptions import NoSuchElementException, StaleElementReferenceException
- from selenium.webdriver.common.keys import Keys
- from pymongo import MongoClient
- from bson.objectid import ObjectId
- from random import randint, choice
- username = sys.argv[1]
- password = sys.argv[2]
- def main():
- driverPath = cfg.app['driverPath']
- dataPath = './profile/'+username
- options = webdriver.ChromeOptions()
- options.add_argument("--user-data-dir=" + dataPath)
- if cfg.app['headless']:
- options.add_argument('headless')
- if cfg.app['no-sandbox']:
- options.add_argument('no-sandbox')
- options.add_argument(
- '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')
- driver = webdriver.Chrome(chrome_options=options, executable_path=driverPath)
- webpage = "https://someweb.domain"
- driver.get(webpage)
- # humanize a thing
- time.sleep(randint(3, 10))
- username_form = driver.find_elements_by_css_selector('input.username"][type="text"]')
- if len(username_form) > 0:
- password_form = driver.find_element_by_css_selector('input[type="password"]')
- submit_btn = driver.find_element_by_css_selector('form[method="post"]')
- username_form.send_keys(username)
- password_form.send_keys(password)
- submit_btn.submit()
- time.sleep(randint(4,10)) # randSLOWare ?
- time.sleep(randint(3,9))
- queue = mongo("queue")
- while True:
- status = queue.find({"username": username, "status": "queued"}).sort([("_id", 1)])
- for post in status:
- check_next = is_next(post["_id"])
- if check_next == "cuss":
- tacko = get_tacko(str(post["client"]).split("<@!@>"))
- status_box = driver.find_element_by_css_selector("main textarea")
- status_box.send_keys(tacko)
- give_tacko = driver.find_element_by_css_selector('div[role="button"] > div')
- give_tacko.click()
- total_plus(post["_id"], tacko)
- time.sleep(3)
- elif check_next == "kelar":
- post["status"] = "success"
- queue.update({"_id": ObjectId(str(post["_id"]))}, post)
- ''' HUMANIZE A THING '''
- time.sleep(randint(7, 16))
- driver.get(webpage)
- time.sleep(randint(8,13))
- def mongo(col):
- client = MongoClient("mongodb://127.0.0.1/27017")
- db = client["mydb"]
- col = db[col]
- return col
- def get_tacko(arr):
- return str(choice(arr))
- def total_plus(queue_id, tacko):
- queue = mongo("queue")
- check = queue.find_one({"_id": ObjectId(str(queue_id))})
- if check:
- current_total = int(str(check["total"]))
- current_total += 1
- ltacko = str(check["tacko"]).split("<@!@>")
- ltacko.remove(tacko)
- tackos = "<@!@>".join(ltacko)
- check["total"] = current_total
- check["latest_post"] = int(time.strftime("%Y%m%d%H%M"))
- check["tackos"] = tackos
- queue.update({"_id": ObjectId(str(queue_id))}, check)
- def is_next(queue_id):
- queue = mongo("queue")
- check = queue.find_one({"_id": ObjectId(str(queue_id))})
- if check:
- # already stored as integer in mongodb
- total_times = int(check["total_post"])
- total_now = int(check["total"])
- tacko_every = int(check["tacko_every"])
- latest_tacko = int(check["latest_tacko"])
- if total_now < total_times:
- now = int(time.strftime("%Y%m%d%H%M"))
- cout = now - latest_tacko
- if cout >= tacko_every:
- return "cuss" # continue
- else:
- return "sabar" # please wait
- else:
- return "kelar" # done, change to "success"
- else:
- return "gada"
- if __name__ == '__main__':
- main()
Add Comment
Please, Sign In to add comment