forked from edgarminers/python-edgar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
45 lines (36 loc) · 1.17 KB
/
run.py
File metadata and controls
45 lines (36 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from __future__ import print_function
import os
import datetime
import tempfile
import sys
from argparse import ArgumentParser
import logging
import edgar
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
ch = logging.StreamHandler(sys.stdout)
ch.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
ch.setFormatter(formatter)
logger.addHandler(ch)
if __name__ == "__main__":
parser = ArgumentParser()
parser.add_argument(
"-y",
"--from-year",
type=int,
dest="year",
help='The year from which to start downloading ' +
'the filing index. Default to current year',
default=datetime.date.today().year)
parser.add_argument(
"-d",
"--directory",
dest="directory",
help='A directory where the filing index files will' +
'be downloaded to. Default to a temporary directory',
default=tempfile.mkdtemp())
args = parser.parse_args()
logger.debug("downloads will be saved to %s" % args.directory)
edgar.download_index(args.directory, args.year)
logger.info("Files downloaded in %s" % args.directory)