Reputation: 233
I have to scrape data from a website. I have to click on each date from june 2019 to july 2019 and download data from that resulting page. Right now, I am unable to click on the calender icon and enter dates which is stopping me to go further. Is there a way to do this?
import bs4
from selenium import webdriver
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support.select import Select
link = "http://apsdps.ap.gov.in/pages/reports_web/reports_daily_mandalwise.html"
webdriver.Chrome(executable_path=r"chromedriver.exe")
driver = webdriver.Chrome()
driver.get(link)
driver.find_element_by_xpath("//span[@class='Zebra_DatePicker_Icon_Wrapper']").click
Upvotes: 0
Views: 222
Reputation: 13349
This is How I did in my project. Use send_keys to enter the date.
# //*[@id="txtDateFrom"]
datefield = driver.find_element_by_xpath('//*[@id="txtDateFrom"]')
datefield.click()
datefield.clear()
datefield.send_keys("01/01/2018")
time.sleep(4)
datefield = driver.find_element_by_xpath('//*[@id="txtDateTo"]')
datefield.click()
datefield.clear()
datefield.send_keys("3/02/2018")
Upvotes: 0
Reputation: 1938
The element is within iframe. you have to switch to the iframe and try click on the element.
driver.switch_to_frame(driver.find_element_by_xpath("//iframe"))
driver.find_element_by_name("date1").click()
Upvotes: 2