I am trying to get the data from this web page https://rapor.epias.com.tr/rapor/xhtml/ptfSmfListeleme.xhtml As you can see I need to pick a beginning and end date and get the data. But the problem is when u open the calendar you can see the non-active days too especially at the final date.
I write a code for the beginning date and it is worked well but it is not practical.
import re
import time
from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
url = r'https://rapor.epias.com.tr/rapor/xhtml/ptfSmfListeleme.xhtml'
driver = webdriver.Chrome(r'...\chromedriver.exe')
driver.get(url)
link = driver.find_element_by_xpath('//*[@id="PmumBI:baslangicTarih"]/button/span[1]')
link.click()
while True:
try:
input_date = driver.find_element_by_xpath('//*[@id="ui-datepicker-div"]/table/tbody/tr[1]/td[1]/a')
input_date.click()
except:
try:
input_date = driver.find_element_by_xpath('//*[@id="ui-datepicker-div"]/table/tbody/tr[1]/td[2]/a')
input_date.click()
except:
try:
input_date = driver.find_element_by_xpath('//*[@id="ui-datepicker-div"]/table/tbody/tr[1]/td[3]/a')
input_date.click()
except:
try:
input_date = driver.find_element_by_xpath('//*[@id="ui-datepicker-div"]/table/tbody/tr[1]/td[4]/a')
input_date.click()
except:
try:
input_date = driver.find_element_by_xpath('//*[@id="ui-datepicker-div"]/table/tbody/tr[1]/td[5]/a')
input_date.click()
except:
try:
input_date = driver.find_element_by_xpath('//*[@id="ui-datepicker-div"]/table/tbody/tr[1]/td[6]/a')
input_date.click()
except:
try:
input_date = driver.find_element_by_xpath('//*[@id="ui-datepicker-div"]/table/tbody/tr[1]/td[7]/a')
input_date.click()
except:
break
But I if I want to use the same for the final date I have to create more then 7 try code. Is there any way to make this simple, Like choosing between the active dates?