import [Link].
By;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link].*;
import [Link].*;
public class DateChecker {
public static void main(String[] args) {
// Set the path to your ChromeDriver
[Link]("[Link]", "/path/to/chromedriver");
// Create a ScheduledExecutorService to run tasks periodically
ScheduledExecutorService scheduler = [Link](1);
// Schedule the task to run every 1 hour
[Link](() -> {
checkAndSendEmail();
}, 0, 1, [Link]); // Change the interval as needed
}
public static void checkAndSendEmail() {
// Initialize WebDriver
WebDriver driver = new ChromeDriver();
[Link]().timeouts().implicitlyWait(10, [Link]);
try {
// Open the webpage with the datepicker
[Link]("[Link]
// Find the earliest available date (adjust the XPath to match the
available date elements)
WebElement earliestDateElement =
[Link]([Link]("//td[not(contains(@class, 'ui-state-disabled'))]/a"));
String earliestDate = [Link]();
// Check if the earliest available date is in 2024
if ([Link]("2024")) {
// Send an email notification
sendEmailNotification(earliestDate);
}
} catch (Exception e) {
[Link]();
} finally {
// Close the browser
[Link]();
}
}
public static void sendEmailNotification(String date) {
// Sender's email address
String senderEmail = "your_email@[Link]";
// Sender's password
String senderPassword = "your_password";
// Recipient's email address
String recipientEmail = "recipient_email@[Link]";
// SMTP server properties
Properties props = new Properties();
[Link]("[Link]", "true");
[Link]("[Link]", "true");
[Link]("[Link]", "[Link]"); // Change this to your
SMTP server
[Link]("[Link]", "587"); // Change this to your SMTP port
// Create a session
Session session = [Link](props, new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(senderEmail, senderPassword);
}
});
try {
// Create a message
Message message = new MimeMessage(session);
[Link](new InternetAddress(senderEmail));
[Link]([Link],
[Link](recipientEmail));
[Link]("Earliest Date Available in 2024");
[Link]("The earliest date available in 2024 is: " + date);
// Send the message
[Link](message);
[Link]("Email notification sent successfully.");
} catch (MessagingException e) {
[Link]();
}
}
}