-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcookie_clicker
49 lines (36 loc) · 1.43 KB
/
cookie_clicker
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time
service = Service(executable_path="chromedriver.exe")
driver = webdriver.Chrome(service=service)
driver.get("https://orteil.dashnet.org/cookieclicker/")
# https://orteil.dashnet.org/cookieclicker/
cookie_id = "bigCookie"
cookies_id = "cookies"
product_price_prefix = "productPrice"
product_prefix = "product"
WebDriverWait(driver, 5).until(
EC.presence_of_element_located((By.ID, "langSelect-EN"))
)
input_element = driver.find_element(By.ID, "langSelect-EN")
input_element.click()
WebDriverWait(driver, 5).until(
EC.presence_of_element_located((By.ID, cookie_id))
)
cookie = driver.find_element(By.ID, cookie_id)
while True:
cookie.click()
cookies_count = driver.find_element(By.ID, cookies_id).text.split(" ")[0]
cookies_count = int(cookies_count.replace(",", ""))
for i in range(4):
product_price = driver.find_element(By.ID, product_price_prefix + str(i)).text.replace(",", "")
if not product_price.isdigit():
continue
product_price = int(product_price)
if cookies_count >= product_price:
product = driver.find_element(By.ID, product_prefix + str(i))
product.click()
break