-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcovidsignups.py
More file actions
77 lines (61 loc) · 2.22 KB
/
covidsignups.py
File metadata and controls
77 lines (61 loc) · 2.22 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import time
import datetime
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
file = open('num.txt', 'r')
num = file.read()
# variables
date = ""
sunday = ""
tuesday = "_tuesday"
thursday = "_thursday"
url = "https://www.signupgenius.com/go/amherst_spring" + num
print(url)
i = 0
# xpath variables
button_xpath = "//*[starts-with(@id,'checkbox')]"
first_xpath = "//input[@id='firstname']"
last_xpath = "//input[@id='lastname']"
email_xpath = "//input[@id='email']"
# initialize driver
driver = webdriver.Chrome("C:\\Users\\clair\\Desktop\\python projects\\chromedriver.exe")
while(i != 3):
# check date
if date == sunday:
url = "https://www.signupgenius.com/go/amherst_spring" + num
print(url)
date = "_tuesday"
elif date == tuesday:
url = "https://www.signupgenius.com/go/amherst_spring" + num + date
date = "_thursday"
elif date == thursday:
url = "https://www.signupgenius.com/go/amherst_spring" + num + date
date = ""
i += 1
driver.get(url)
# find first signup button on the list, select and click submit
button = driver.find_element_by_xpath(button_xpath).send_keys(' ')
sumbit = driver.find_element_by_class_name("giantsubmitbutton.rounded.link_cursor").send_keys(' ')
# WebDriverWait(driver, 1000)
#.until(EC.presence_of_element_located((By.ID, "firstname"))
wait = WebDriverWait(driver, 20).until(
EC.presence_of_element_located((By.ID, "firstname")))
fill_first_name = driver.find_element_by_id('firstname').send_keys("Claire")
fill_last_name = driver.find_element_by_xpath(last_xpath).send_keys("Jensen")
fill_email = driver.find_element_by_xpath(email_xpath).send_keys("cjensen24@amherst.edu")
fill_email = driver.find_element_by_name('btnSignUp').send_keys(' ')
# go back to main page
driver.implicitly_wait(4)
back_to_signup = driver.find_element_by_class_name("btn.btn-xl.btn-success.ng-binding")
# quit driver
driver.quit()
# increase num every week
num = int(num)
num += 1
num = str(num)
file.close()
file = open('num.txt', 'w')
file.write(num)
file.close()