【问题标题】:Downloading Excel files from SEC从 SEC 下载 Excel 文件
【发布时间】:2015-04-20 21:55:33
【问题描述】:
有没有一种方法可以自动从 EDGAR 中的 Interactive Data 网页下载 excel 文件以获取代码列表,而无需手动搜索 EDGAR 上的每个代码?或者有没有一种方法可以为一系列公司访问 XBRL,而无需再次物理访问 EDGAR 中的每个页面?我遇到了麻烦,因为我无法弄清楚如何生成唯一的 URL,因为最后六个数字与那一年的归档顺序和帐号有关。
【问题讨论】:
标签:
financial
data-extraction
xbrl
【解决方案1】:
Edgar 没有 API。我编写了一个包作为 Edgar 的接口,允许通过代码进行搜索。解析搜索结果页面的位如下。整个文件在https://github.com/andrewkittredge/financial_fundamentals/blob/master/financial_fundamentals/edgar.py。
SEARCH_URL = ('http://www.sec.gov/cgi-bin/browse-edgar?action=getcompany&'
'CIK={symbol}&type={filing_type}&dateb=&owner=exclude&count=100')
def _get_document_page_urls(symbol, filing_type):
'''Get the edgar filing document pages for the CIK.
'''
search_url = SEARCH_URL.format(symbol=symbol, filing_type=filing_type)
search_results_page = get_edgar_soup(url=search_url)
xbrl_rows = [row for row in
search_results_page.findAll('tr') if
row.find(text=re.compile('Interactive Data'))]
for xbrl_row in xbrl_rows:
documents_page = xbrl_row.find('a', {'id' : 'documentsbutton'})['href']
documents_url = 'http://sec.gov' + documents_page
yield documents_url