Python - 执行脚本时出错

时间:2015-02-18 15:17:27

标签: python

我正在尝试执行this 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() 

我将此代码放在文件filings.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'

我做错了什么?

2 个答案:

答案 0 :(得分:1)

看起来您安装的软件包出现错误。 尝试卸载并重新安装。

pip uninstall SECEdgar

pip install SECEdgar

答案 1 :(得分:0)

我找到了解决方案,这基本上是一件非常愚蠢的事情:

date = '20010101'       # date from which filings should be downloaded

应该是

date = '20010101'       # date UNTIL which filings should be downloaded

所以如果你把开始日期放在下载0文件上,但是如果你把结束日期放在那里就可以将它们全部下载成功,那么现在似乎工作正常:)