I'm using Python and Selenium in PyCharm to go to the SEC website to download a 10-K CSV file. Ideally, the program should ask for user input for a "ticker symbol", then go to the SEC's website, input the ticker symbol provided and download the 10-K and 10-Q CSV files from the page. I was using Microsoft's ticker symbol (MSFT) as an example test. The SEC's Edgar search website is this:
https://www.sec.gov/edgar/searchedgar/companysearch.html
and I am using the 'Fast Search' search engine. I created a function 'get_edgar_results' to perform this download. It might be that I'm new to web scraping, but I thought I identified the HTML tags correctly on where to put my search term. Previous problems suggested that I might need to have the program wait before searching for the HTML element, so I added code for the program to wait. I continue getting this error:
line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: [id="Find"]
My code is below:
import selenium.webdriver.support.ui as ui
from pathlib import Path
import selenium.webdriver as webdriver
ticker_symbol = input("please provide a ticker symbol: ")
def get_edgar_results(ticker_symbol):
url = "https://www.sec.gov/edgar/searchedgar/companysearch.html"
driver = webdriver.Firefox(executable_path=r"C:\Program Files\JetBrains\geckodriver.exe")
wait = ui.WebDriverWait(driver,30)
driver.set_page_load_timeout(30)
driver.get(url)
search_box = driver.find_element_by_id("Find")
search_box.send_keys(ticker_symbol)
search_box.submit()
annual_links = driver.find_elements_by_class_name("10-K")
quarterly_links = driver.find_elements_by_class_name("10-Q")
results = []
driver.close()
driver.quit()
return results
get_edgar_results(ticker_symbol)
Any help would be greatly appreciated.