I am using python + Selenium to get some data from this website -
https://www1.nseindia.com/products/content/equities/indices/historical_index_data.htm
I have selected the index, and set the calendar dates. Now when I click on the "Get Data" button on the website, absolutely nothing happens. If I click the Get Data button manually, I get the data, and a link to a CSV file.
Here's my snippet of code -
indexes = Select(driver.find_element_by_xpath('//*[@id="indexType"]'))
indexes.select_by_visible_text("NIFTY 50")
time.sleep(1)
driver.find_element_by_xpath('//*[@id="fromDate"]').click()
month = Select(driver.find_element_by_xpath('//*[@id="ui-datepicker-div"]/div/div/select[1]'))
month.select_by_visible_text('Jan')
year = Select(driver.find_element_by_xpath('//*[@id="ui-datepicker-div"]/div/div/select[2]'))
year.select_by_visible_text('2020')
driver.find_element_by_xpath('//*[@id="ui-datepicker-div"]/table/tbody/tr[1]/td[4]/a').click()
#time.sleep(2)
today = date.today()
yesterday = pd.to_datetime(today) - pd.to_timedelta(1, "D")
m = yesterday.month - 1
y = yesterday.year
#time.sleep(2)
driver.find_element_by_xpath('//*[@id="toDate"]').click()
month = Select(driver.find_element_by_xpath('//*[@id="ui-datepicker-div"]/div/div/select[1]'))
month.select_by_value(str(m))
year = Select(driver.find_element_by_xpath('//*[@id="ui-datepicker-div"]/div/div/select[2]'))
year.select_by_value(str(y))
e = driver.find_element_by_xpath('//*[@id="ui-datepicker-div"]/table')
dates = e.find_elements_by_class_name("ui-state-default")
for d in dates:
if d.text == str(yesterday.day):
ActionChains(driver).click(d).perform()
break
#time.sleep(2)
element = wait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="get"]')))
ActionChains(driver).click(element).perform
I would welcome any suggestions. Thanks in advance.