[英]Python - error when executing script
我正在嘗試執行此腳本 :
import time
from SECEdgar.crawler import SecCrawler
def get_filings():
t1 = time.time()
# create object
seccrawler = SecCrawler()
companyCode = 'AAPL' # company code for apple
cik = '0000320193' # cik code for apple
date = '20010101' # date from which filings should be downloaded
count = '10' # no of filings
seccrawler.filing_10Q(str(companyCode), str(cik), str(date), str(count))
seccrawler.filing_10K(str(companyCode), str(cik), str(date), str(count))
seccrawler.filing_8K(str(companyCode), str(cik), str(date), str(count))
seccrawler.filing_13F(str(companyCode), str(cik), str(date), str(count))
t2 = time.time()
print "Total Time taken: ",
print (t2-t1)
if __name__ == '__main__':
get_filings()
我將此代碼放在文件files.py中,然后嘗試從終端(Mac用戶)運行它
python filings.py
但是我收到以下錯誤:
Traceback (most recent call last):
File "filings.py", line 2, in <module>
from SECEdgar.crawler import SecCrawler
File "build/bdist.macosx-10.10-intel/egg/SECEdgar/crawler.py", line 6, in <module>
File "build/bdist.macosx-10.10-intel/egg/SECEdgar/config.py", line 22, in <module>
File "/Library/Python/2.7/site-packages/configparser.py", line 995, in __getitem__
raise KeyError(key)
KeyError: 'Paths'
我究竟做錯了什么?
您安裝的軟件包中似乎有一個錯誤。 嘗試卸載並重新安裝。
pip uninstall SECEdgar
pip install SECEdgar
我找到了解決方案,這基本上是一件很愚蠢的事情:
date = '20010101' # date from which filings should be downloaded
應該
date = '20010101' # date UNTIL which filings should be downloaded
因此,如果您輸入開始日期,則最終將下載0個文件,但是如果您輸入結束日期,則將成功下載所有文件,似乎現在可以正常進行了:)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.