|
| 1 | + |
| 2 | + |
| 3 | +from selenium import webdriver |
| 4 | +import time |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | +path = "/Users/fahadsmacbook/Downloads/Python 100 Days/Development/chromedriver" |
| 9 | + |
| 10 | +driver = webdriver.Chrome(executable_path=path) |
| 11 | + |
| 12 | + |
| 13 | +#Selenium Auto Form Filler |
| 14 | +driver.get("https://orteil.dashnet.org/cookieclicker/") |
| 15 | +cookie = driver.find_element_by_id('bigCookie') |
| 16 | +driver.maximize_window() |
| 17 | +def upgrade_cookie(cookie_count): |
| 18 | + price = driver.find_elements_by_css_selector("#products .price") |
| 19 | + id = driver.find_elements_by_css_selector("#products .price") |
| 20 | + id_list = [id.get_attribute('id') for id in id] |
| 21 | + print(id_list) |
| 22 | + price = [price.text for price in price] |
| 23 | + print(price) |
| 24 | + for i in range(len(price)): |
| 25 | + if price[i] == "": |
| 26 | + price = price[:i] |
| 27 | + break |
| 28 | + |
| 29 | + # price = [int(price) for price in price] |
| 30 | + new_price = [] |
| 31 | + for a in price: |
| 32 | + b = "" |
| 33 | + a = a.split(",") |
| 34 | + for a in a: |
| 35 | + b = b + a |
| 36 | + b = int(b) |
| 37 | + new_price.append(b) |
| 38 | + print(new_price) |
| 39 | + dict = {new_price[i]: id_list[i] for i in range(len(new_price))} |
| 40 | + print(dict) |
| 41 | + |
| 42 | + cookie_count = driver.find_element_by_id("cookies") |
| 43 | + cookie_count = int(cookie_count.text.split(" ")[0]) |
| 44 | + print(cookie_count) |
| 45 | + cookie_count = cookie_count |
| 46 | + upgrade_price = [money for money in new_price if money < cookie_count] |
| 47 | + print(upgrade_price) |
| 48 | + buy_price = max(upgrade_price) |
| 49 | + to_purchase_id = dict[buy_price] |
| 50 | + print(to_purchase_id) |
| 51 | + buy = driver.find_element_by_id(to_purchase_id) |
| 52 | + |
| 53 | + # buy.click() |
| 54 | + |
| 55 | + |
| 56 | + |
| 57 | +delay=60*15 ###for 15 minutes delay |
| 58 | +close_time=time.time()+delay |
| 59 | +timeout = time.time() + 5 |
| 60 | +five_min = time.time() + 60*5 # 5minutes |
| 61 | + |
| 62 | +while True: |
| 63 | + cookie.click() |
| 64 | + if time.time() > timeout: |
| 65 | + upgrade_cookie() |
| 66 | + |
| 67 | + timeout = time.time() + 5 |
| 68 | + if time.time() > five_min: |
| 69 | + cookie_per_s = driver.find_element_by_id("cps").text |
| 70 | + print(cookie_per_s) |
| 71 | + break |
| 72 | + |
| 73 | + |
| 74 | + |
| 75 | + |
| 76 | + |
0 commit comments