简体   繁体   中英

Python - error when executing script

I am trying to execute 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() 

I am putting this code in a file filings.py , then attempt to run it from terminal (Mac user)

python filings.py

But I am getting the following error:

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'

What am I doing wrong?

Looks like there's an error in the package you installed. Try uninstalling and reinstalling.

pip uninstall SECEdgar

pip install SECEdgar

I found the solution, it was basically a quite silly thing:

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

should be

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

so if you put the starting date you would end up with download 0 files, but if you put the end date then you would download them all successfully, seems to be working OK now :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM