def obtain_document_details(stock_ticker, filing_type): company = Company() company.ticker = stock_ticker sec_uri = 'https://www.sec.gov/cgi-bin/browse-edgar?action=getcompany&CIK={}&type={}&dateb=&owner=include&count=100&output=xml'.format( stock_ticker, filing_type) response = requests.get(sec_uri) page_data = bs4.BeautifulSoup(response.text, "html.parser") company.cik = page_data.companyinfo.cik.string documents = [] for filing in page_data.find_all('filing'): filing_href_string = filing.filinghref.string file_name = os.path.basename((urlparse(filing_href_string)).path) accession_number_str = file_name.split('-index')[0] document = Document() document.company = company document.filing_date = filing.datefiled.string document.filing_type = filing.type.string document.accession_number_str = accession_number_str documents.append(document) return documents