I am building a web scraper to download PDF files from a public school database site, and the script itself works fine with Chrome, which is what I would prefer. However, the site will ONLY allow you to use IE to download files. The script uses Selenium and I've been trying to use the IE driver (both 32 and 64 bit) to no avail. It opens the webpage, but it inputs nothing when I use the send_keys method and I receive no errors. Again, this works fine in Chrome. Here's the code:
from selenium import webdriver
from selenium.webdriver.support.ui import Select
import time
import pandas as pd
url = "https://mdoe.state.mi.us/cms/grantauditorreport.aspx"
districtlist = pd.read_csv(filepath_or_buffer=r'DistrictList.csv',squeeze=True)
for district in districtlist:
ieoptions = webdriver.IeOptions()
driver = webdriver.Ie(executable_path='IEDriverServer.exe',options=ieoptions)
driver.get(url)
search = driver.find_element_by_name("ctl00$cphMain$txtAgency")
search.send_keys('%')
driver.find_element_by_css_selector('.ButtonStandard').click()
select = Select(driver.find_element_by_id('ctl00_cphMain_ddlAgency'))
select.select_by_visible_text(district)
start_date = driver.find_element_by_name("ctl00$cphMain$txtBeginDate")
driver.execute_script("arguments[0].value = ''", start_date)
start_date.send_keys('4/2/2018')
end_date = driver.find_element_by_name("ctl00$cphMain$txtEndDate")
driver.execute_script("arguments[0].value = ''", end_date)
end_date.send_keys('4/9/2021')
driver.find_element_by_name('ctl00$cphMain$btnSearch').click()
time.sleep(10)
driver.quit()
quit()
I'm new to Python and this is my first foray into web scraping or Selenium.
Thanks!
