| 9 | from multiprocessing import Process |
| 10 | |
| 11 | class KickBot(): |
| 12 | def __init__(self, url): |
| 13 | self.url = url |
| 14 | self.driver = None |
| 15 | |
| 16 | def setupWebBrowser(self): |
| 17 | chrome_options = Options() |
| 18 | chrome_options.add_argument("--start-minimized") |
| 19 | chrome_options.add_argument("--mute-audio") |
| 20 | self.driver = uc.Chrome(options=chrome_options) |
| 21 | |
| 22 | def doTest(self): |
| 23 | self.setupWebBrowser() |
| 24 | self.driver.get(self.url) |
| 25 | not_found_count = 0 |
| 26 | while True: |
| 27 | try: |
| 28 | |
| 29 | button = self.driver.find_element(By.CSS_SELECTOR, "button.variant-action.size-sm") |
| 30 | |
| 31 | button.click() |
| 32 | print("Button clicked!") |
| 33 | not_found_count = 0 |
| 34 | except NoSuchElementException: |
| 35 | |
| 36 | if "Oops, Something went wrong" in self.driver.page_source: |
| 37 | self.driver.refresh() |
| 38 | print("Page refreshed!") |
| 39 | not_found_count = 0 |
| 40 | elif not_found_count >= 10: |
| 41 | print("Watch now button not found after 10 attempts. Stopping search.") |
| 42 | break |
| 43 | elif "Checking if the site connection is secure" in self.driver.page_source: |
| 44 | self.driver.close() |
| 45 | sleep(5) |
| 46 | self.setupWebBrowser() |
| 47 | self.driver.get(self.url) |
| 48 | print("Browser restarted") |
| 49 | else: |
| 50 | print("Watch now button not found on this page") |
| 51 | not_found_count += 1 |
| 52 | sleep(10) |
| 53 | |
| 54 | def run_script(url, num_threads): |
| 55 | processes = [] |
no outgoing calls
no test coverage detected