-
Notifications
You must be signed in to change notification settings - Fork 0
/
tracker.py
50 lines (43 loc) · 1.87 KB
/
tracker.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
from sendemail import sendNotification
import time
from selenium import webdriver
import os
from dotenv import load_dotenv
load_dotenv()
options = webdriver.ChromeOptions()
options.add_argument("--disable-infobars")
# options.add_argument("--headless")
# Uncoment to enable Headless version
options.add_argument("--start-maximized")
options.add_argument(
"user-agent='User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36'"
)
def main():
pincode = list(map(int, os.getenv("PINCODES").split(" ")))
while True:
browser = webdriver.Chrome(options=options)
for pin in pincode:
browser.get("https://www.cowin.gov.in/")
browser.implicitly_wait(10)
browser.find_element_by_id('mat-input-0').send_keys(pin)
browser.implicitly_wait(10)
time.sleep(10)
browser.find_element_by_xpath(
"//*[@id=\"mat-tab-content-0-0\"]/div/div[1]/div/div/button").click()
time.sleep(10)
browser.find_element_by_xpath(
"//*[@id=\"Search-Vaccination-Center\"]/appointment-table/div/div/div/div/div/div/div/div/div/div/div[2]/form/div/div/div[2]/div[3]/ul/li[2]/div/div[2]/label").click()
time.sleep(10)
try:
browser.find_element_by_xpath(
"//*[@id=\"Search-Vaccination-Center\"]/appointment-table/div/div/div/div/div/div/div/div/div/div/div[2]/form/div/div/div[5]/div[3]/div/div/div[1]/p")
# No slots
print("No shots available at Pincode:", pin)
except:
# sendemail()
sendNotification()
browser.quit()
print("Vaccine Not Available. Checing Again in 1 hr.")
time.sleep(3600) #Enter time(in sec) in which script will re-run
if __name__ == "__main__":
main()