I am trying to scrape Federal reserve's press releases on https://www.federalreserve.gov/newsevents/pressreleases.htm
, but have to impose some filters before I can actually scrape stuff.
In particular, have to do the following:
- Select Monetary Policy under Filters (it works thanks to the suggestions here)
- Specify a date range under Date (from 01/01/2010 to 12/31/2021)
- Finally, click on Submit button once both the filters are imposed.
For 2., I tried the following but it returned a NoSuchElementException
.
date_input = driver.find_element_by_xpath('//*[@id="content"]/div[2]/div/div[1]/form/div[2]/div/div[1]/input')
date_input.click() # Focus input field
date_input.send_keys(Keys.CONTROL, "a") # Select all pre-existing text/input value
date_input.send_keys(Keys.BACKSPACE) # Remove that text
date_input.send_keys("01012010") # Add desired text/set input value
For 3., I modified the code from here and tried the following:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.LINK_TEXT, "Submit"))).click() #submit the filter
and
WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH ,"//*[@id='content']/div[2]/div/div[1]/form/div[5]/a"))).click()
but both don't work.
Any ideas? Thanks!