Mar-06-2019, 04:11 PM
First of all, I would like to say I am very new to Python and web-scraping so I apologise if I am missing something quite obvious. I am trying to webscrape an iframe object containing a list of links. The ultimate objective is to perform a series of actions, which is the same for each link, that leads to downloading some data in xls format.
For each of the links in the iframe, I want to automate the following actions: 1. click on the link 2.select from a drop down list the option for getting data since 1999 3.click on the excel download button.
My code works for the first one of the links, but I am struggling with automating it to go through all the links in the iframe.
This is the code that works for the first link:
Thanks!
For each of the links in the iframe, I want to automate the following actions: 1. click on the link 2.select from a drop down list the option for getting data since 1999 3.click on the excel download button.
My code works for the first one of the links, but I am struggling with automating it to go through all the links in the iframe.
This is the code that works for the first link:
#this automates the log in driver.find_element_by_id('user').send_keys('myusername') driver.find_element_by_id('password').send_keys('mypassword') driver.find_element_by_xpath('myxpath').click() #this switches to iframe and clicks on all the links driver.switch_to.frame("report-iframe") driver.find_element_by_tag_name('a').click() #this performs the required actions for the first link(select drop down, select excel download) s= Select(driver.find_element_by_id('start-date')) s.select_by_value('1999-01-01') driver.find_element_by_xpath('//*[@id="report-excel-download"]') wait = WebDriverWait(driver, 10) element = wait.until(EC.element_to_be_clickable((By.ID, 'report-excel-download'))) element.click()I want to automate this process for all the links in the iframe (i.e. for each of the links in iframe, click on the link, select the drop down, click the data download button. Does anyone have any advice in how to do this?
Thanks!