# Click on the calendar element
input_element = driver.find_element(By.CSS_SELECTOR, 'input.dates-container.form-control')
input_element.click()

for _ in range(2):
    # Find the left part of the calendar
    start_calendar = driver.find_element(By.CSS_SELECTOR, '.drp-calendar.left')

    # Select the desired option value for monthselect
    month_select = Select(start_calendar.find_element(By.CSS_SELECTOR, '.monthselect'))
    month_select.select_by_value("10") 

    # Re-find the start calendar element to avoid StaleElementReferenceException
    start_calendar = driver.find_element(By.CSS_SELECTOR, '.drp-calendar.left')

    # Find the yearselect element within start_calendar and select the desired option value
    year_select = Select(start_calendar.find_element(By.CSS_SELECTOR, '.yearselect'))
    year_select.select_by_value("2021")
    
# Get the selected month and year from the dropdowns using the custom function
selected_month = int(month_select.first_selected_option.get_attribute("value"))
selected_year = int(year_select.first_selected_option.get_attribute("value"))

# Get the number of days in the month
num_days_in_month = calendar.monthrange(selected_year, selected_month+1)[1]

# Create a datetime object for the first and last day of the selected month and year
first_day = datetime.date(selected_year, selected_month+1, 1)
last_day = datetime.date(selected_year, selected_month+1, num_days_in_month)

# Use the weekday() method to get the day of the week (0-6, where 0 is Monday and 6 is Sunday)
day_of_week_for_first_day = first_day.weekday()
day_of_week_for_last_day = last_day.weekday()

# Determine the week number of the first day and last day using %U for the week number starting from Sunday
week_number_for_first_day = first_day.isocalendar()[1]
week_number_for_last_day = last_day.isocalendar()[1]

# Convert the date into a string with the format “YYYY-MM-DD”
first_day_str = first_day.strftime("%Y-%m-%d")
last_day_str = last_day.strftime("%Y-%m-%d")

# Get the last two digits and add a remaining “0” before the last digit
last_two_digits_for_first_day = first_day_str[-2:].zfill(2)
last_two_digits_for_last_day = last_day_str[-2:].zfill(2)

# Get the row number for the first and last day
week_number_remainder_for_first_day = (week_number_for_first_day - 1) % 6
week_number_remainder_for_last_day = (week_number_for_last_day - 1) % 6

# Find the calendar element
start_calendar = driver.find_element(By.CSS_SELECTOR, '.drp-calendar')

for _ in range(2): # Нажимаем дважды одну и ту же дату, так как выгрузка по дням
    # Find the specific day element
    day_element = start_calendar.find_element(By.CSS_SELECTOR, f"td[data-title='r{week_number_remainder_for_first_day}c{day_of_week_for_first_day}']")

    # Click on the day element to select it
    day_element.click()
    
# Find the select button
dropdown_select = driver.find_element(By.XPATH, "//button[contains(text(), 'Выбор')]")

# Click on the select button
dropdown_select.click()

# Find the update button
dropdown_update = driver.find_element(By.XPATH, "//button[contains(text(), 'Обновить ')]")

# Click on the update button
dropdown_update.click()

I need to add the last part of code to click on button Excel to load data to specified folder with specified name of file. Modify the code given below. I'm not sure that driver = webdriver.Chrome(options=chrome_options) is needed beacuse it produces anothe web page

# Specify the file name
file_name = f"{last_two_digits_for_first_day}.{selected_month+1}.{selected_year}"

# Specify the desired download path
download_path = r"C:\Users\snoale\Рабочие файлы\CF Department\Data"

# Set the preferences for ChromeOptions
chrome_options = Options()
chrome_options.add_experimental_option("prefs", {
"download.default_directory": download_path,
"download.prompt_for_download": False,
"download.directory_upgrade": True,
"safebrowsing.enabled": True,
"download.default_filename": file_name
})

# Instantiate the WebDriver with ChromeOptions
driver = webdriver.Chrome(options=chrome_options)

# Click the “Excel” button to initiate file download
excel_button = driver.find_element(By.XPATH, "//button[contains(text(), 'Excel')]")
excel_button.click()