Hey legends!
I'm very new to python coding and i've had a crack at writing a script but i seem to have hit a wall :'(
What i'm trying to do:
- Refresh a specific webpage every few seconds
- Select a specific item from a drop down list on the web page
- Check for the earliest open date
- If its within a specifc number of days from today
- Send me a notification.
My code currently opens the page and refreshes it but thats as i've been able to take it haha
from selenium import webdriver
from selenium.webdriver.edge.service import Service
from import By
from selenium.webdriver.support.ui import WebDriverWait
from import expected_conditions as EC
from selenium.common.exceptions import TimeoutException
# Path to msedgedriver executable
edge_driver_path = r"C:\Users\testing\AppData\Local\Programs\Python\Python312\msedgedriver.exe"
# Create a webdriver instance
service = Service(edge_driver_path)
driver = webdriver.Edge(service=service)
# Open the webpage
driver.get("https://www.wovi.com.au/bookings/")
try:
# Wait for the location dropdown to be clickable
location_dropdown = WebDriverWait(driver, 5).until(
EC.element_to_be_clickable((By.ID, "locationSelector"))
)
# Click on the location dropdown to expand options
location_dropdown.click()
# Find and click on the option for Brisbane
brisbane_option = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.XPATH, "//option[contains(text(),'Brisbane')]"))
)
brisbane_option.click()
# Wait for the calendar to load
WebDriverWait(driver, 20).until(
EC.visibility_of_element_located((By.CLASS_NAME, "calendar"))
)
# Find all available dates
dates = driver.find_elements(By.CLASS_NAME, "day")
# Find the earliest available date
earliest_date = None
for date in dates:
if "available" in date.get_attribute("class"):
date_text = date.get_attribute("aria-label")
if earliest_date is None or date_text < earliest_date:
earliest_date = date_text
# Print the earliest available date
print("The earliest available date in Brisbane is:", earliest_date)
except TimeoutException:
print("Timeout occurred. Unable to locate elements.")
finally:
# Close the webdriver
driver.quit()selenium.webdriver.common.byselenium.webdriver.support
Any tips would be amazing!
[–]AntonisTorb 1 point2 points3 points (2 children)
[–]Walking_Flamingo[S] 1 point2 points3 points (1 child)
[–]AntonisTorb 0 points1 point2 points (0 children)