-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
57 lines (46 loc) · 1.74 KB
/
main.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
# setup
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
import time
import datetime
# ---user configurable options--- #
ics4uLink = "https://docs.google.com/spreadsheets/d/17mWdVgPJ0xo1qb0GAQLTVXSLu1_jl8bqeM3H4McVFeI/edit#gid=0&range=D2" # paste in your link to the cell from the attendance spreadsheet
tej34mLink = "https://docs.google.com/spreadsheets/d/1kPNp01St8eahSrfadigF5NHyBvvdxaplhzLufCYWfpU/edit#gid=0&range=D1" # paste in your link to the cell from the attendance spreadsheet
driver = webdriver.Chrome() #uncomment whatever browser you use
#driver = webdriver.Edge()
# driver = webdriver.Firefox()
delay = 2 # seconds passing after column created
# ---user configurable options--- #
# create datetime object from datetime class then format nicely
currentDate = datetime.datetime.now().strftime("%b %d")
actions = ActionChains(driver)
# create new column to left, with via Actions API/Action Chains
# stores actions then performs them
# ics4u
# open link to cell
driver.get(ics4uLink)
actions.key_down(Keys.LEFT_ALT).key_down(Keys.LEFT_SHIFT)
actions.send_keys("i").send_keys("c")
time.sleep(1)
actions.send_keys("c")
actions.key_up(Keys.LEFT_ALT).key_up(Keys.LEFT_SHIFT)
actions.send_keys(currentDate).send_keys(Keys.RETURN)
actions.perform()
# delay
time.sleep(delay)
# clear actions object
actions.reset_actions()
# tej34m
driver.get(tej34mLink)
actions.key_down(Keys.LEFT_ALT).key_down(Keys.LEFT_SHIFT)
actions.send_keys("i").send_keys("c")
time.sleep(1)
actions.send_keys("c")
actions.key_up(Keys.LEFT_ALT).key_up(Keys.LEFT_SHIFT)
actions.send_keys(currentDate).send_keys(Keys.RETURN)
actions.perform()
# delay
time.sleep(delay)
# quit browser
driver.quit()