-
Notifications
You must be signed in to change notification settings - Fork 0
/
duolingo-streak-refresh.py
61 lines (47 loc) · 2.17 KB
/
duolingo-streak-refresh.py
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
50
51
52
53
54
55
56
57
58
59
60
61
import time
import selenium
from selenium import webdriver
class refresh_streak:
def __init__(self):
chrome_options = webdriver.ChromeOptions()
preferences = {"profile.default_content_setting_values.notifications": 2}
chrome_options.add_experimental_option("prefs", preferences)
self.bot = webdriver.Chrome(executable_path='./chromedriver', options=chrome_options)
def refresh(self, email, password):
duo = self.bot
flag = True
while flag:
try:
duo.get('https://www.duolingo.com/')
# trying to click the 'I already have an account button'
links = duo.find_elements_by_tag_name('a')
for possible_buttons in links:
if possible_buttons.text == 'I ALREADY HAVE AN ACCOUNT':
possible_buttons.click()
time.sleep(1)
# typing the credentials in the input and pressing the login button
inputs = duo.find_elements_by_tag_name('input')
inputs[0].send_keys(email)
inputs[1].send_keys(password)
# ----------- find a different way to make this work, classes are static ----------- #
duo.find_element_by_class_name('_2oW4v').click()
time.sleep(2)
# ----------- find a different way to make this work, classes are static ----------- #
# buying the streak freeze
duo.get('https://www.duolingo.com/shop')
time.sleep(5)
lis = duo.find_elements_by_tag_name('li')
while len(lis) == 0:
lis = duo.find_elements_by_tag_name('li')
for li in lis:
if 'Streak Freeze' in li.get_attribute('outerHTML'):
li.find_element_by_tag_name('button').click()
flag = False
except:
duo.close()
duo.close()
if __name__ == '__main__':
while True:
bot = refresh_streak()
bot.refresh('[email protected]', '[email protected]')
time.sleep(21600) # runs every six hours