Class VaccineChecker
java.lang.Object
VaccineChecker
public class VaccineChecker
extends java.lang.Object
A Java Program that scrapes https://vaccinespotter.org using Selenium
with a personalized URL, based on supplied criteria in a JSON config file,
to see if a vaccine appointment might be available. If so, the program will
send an email or emails to the desired person or people in the JSON config file
letting them know of the possible appointment and with a link to check the site
and book an appointment
- Version:
- 1.5
- Author:
- Jack N. Stockley
-
Constructor Summary
Constructors Constructor Description VaccineChecker() -
Method Summary
Modifier and Type Method Description private static voidaddEmail(java.io.BufferedReader reader, java.lang.String file, boolean update)Adds an email account to the passed config file.private static voidaddPerson(java.io.BufferedReader reader, java.lang.String file, boolean update)Adds a person to the passed config file.private static voidchangeEmail(java.io.BufferedReader reader, java.lang.String file)Program to allow updating email account config, runs removeEmail and then addEmailprivate static voidchangePerson(java.io.BufferedReader reader, java.lang.String file)Program to allow updating people check, runs removePerson and then addPersonprivate static booleanfindAppointments(org.openqa.selenium.WebDriver browser, java.lang.String url, java.lang.String date)Scraps https://vaccinespotter.org for available appointments based on persons criteriaprivate static java.lang.String[]getEmailConf(java.lang.String filePath)Helper function to get the required data to send an email if a vaccine is availablestatic voidmain(java.lang.String[] args)The main function to run the programprivate static voidremoveEmail(java.io.BufferedReader reader, java.lang.String file, boolean update)Removes an email account from the passed config file.private static voidremovePerson(java.io.BufferedReader reader, java.lang.String file, boolean update)Removes a person from the passed config file.private static voidsendEmail(java.lang.String url, java.lang.String name, java.util.List<java.lang.String> emailAddress, java.lang.String file)Sends an email to the user(s) that a vaccine appointment might be availableprivate static voidsetup(java.lang.String filepath)Helper function to help with setting up a JSON config file to work with Vaccine Checker programprivate static voidupgradeConfig(java.lang.String file)Helper function to help with upgrading old config file if new features are addedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
VaccineChecker
public VaccineChecker()
-
-
Method Details
-
addEmail
private static void addEmail(java.io.BufferedReader reader, java.lang.String file, boolean update)Adds an email account to the passed config file. Helps with sending an email when an appointment might be available.- Parameters:
reader- The BufferedReader to help with getting input from the console to pass to the JSON config filefile- A valid JSON file path to store the email config toupdate- True if the program is being called from an update function, false otherwise
-
changeEmail
private static void changeEmail(java.io.BufferedReader reader, java.lang.String file)Program to allow updating email account config, runs removeEmail and then addEmail- Parameters:
reader- The BufferedReader to help with getting input from the console to pass to the JSON config filefile- A valid JSON file path to store the email config to
-
removeEmail
private static void removeEmail(java.io.BufferedReader reader, java.lang.String file, boolean update)Removes an email account from the passed config file.- Parameters:
reader- The BufferedReader to help with getting input from the console to pass to the JSON config filefile- A valid JSON file path to remove the email config fromupdate- True if the program is being called from an update function, false otherwise
-
addPerson
private static void addPerson(java.io.BufferedReader reader, java.lang.String file, boolean update)Adds a person to the passed config file. Checks the person against data scrapped from vaccinespottter.org to see if a vaccine appointment is available- Parameters:
reader- The BufferedReader to help with getting input from the console to pass to the JSON config filefile- A valid JSON file path to store the email config toupdate- True if the program is being called from an update function, false otherwise
-
changePerson
private static void changePerson(java.io.BufferedReader reader, java.lang.String file)Program to allow updating people check, runs removePerson and then addPerson- Parameters:
reader- The BufferedReader to help with getting input from the console to pass to the JSON config filefile- A valid JSON file path to store the email config to
-
removePerson
private static void removePerson(java.io.BufferedReader reader, java.lang.String file, boolean update)Removes a person from the passed config file.- Parameters:
reader- The BufferedReader to help with getting input from the console to pass to the JSON config filefile- A valid JSON file path to remove the email config fromupdate- True if the program is being called from an update function, false otherwise
-
upgradeConfig
private static void upgradeConfig(java.lang.String file)Helper function to help with upgrading old config file if new features are added- Parameters:
file- The old JSON config file to be updated
-
setup
private static void setup(java.lang.String filepath)Helper function to help with setting up a JSON config file to work with Vaccine Checker program- Parameters:
filepath- The JSON config file path to be modified
-
getEmailConf
private static java.lang.String[] getEmailConf(java.lang.String filePath)Helper function to get the required data to send an email if a vaccine is available- Parameters:
filePath- The JSON config file with the required data- Returns:
- A string array with the data from the JSON config file
-
sendEmail
private static void sendEmail(java.lang.String url, java.lang.String name, java.util.List<java.lang.String> emailAddress, java.lang.String file)Sends an email to the user(s) that a vaccine appointment might be available- Parameters:
url- Personalized website url which shows the user where, when, and type of vaccine that might be available. Link direct user to https://vaccinespotter.orgname- The name of person who might have an appointment that meets their criteriaemailAddress- The extra email addresses that will be BCC, if any, the same emailfile- The JSON config file with email data
-
findAppointments
private static boolean findAppointments(org.openqa.selenium.WebDriver browser, java.lang.String url, java.lang.String date)Scraps https://vaccinespotter.org for available appointments based on persons criteria- Parameters:
browser- WebDriver which is used to scrap the web site and find appointmentsurl- Personalized url to https://vaccinespotter.org which is used to determine if an appointment is available based on their criteriadate- Optional date of when the user needs to get the vaccine- Returns:
- True if a vaccine might be available otherwise false
-
main
public static void main(java.lang.String[] args)The main function to run the program- Parameters:
args- Arguments to run the program. Requires at least one. If only one argument is supplied, it should be a JSON config file and will run the setup part of the program. If two arguments are provided they should be a JSON config file and a msedgedriver, in that order, this will run the checking part of the program. If a third argument supplied the program will check for appointment but will not send an email, this should only be used for testing purposes.
-