forked from FinanceData/OpenDartReader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dart_report.py
45 lines (38 loc) · 1.43 KB
/
dart_report.py
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
#-*- coding:utf-8 -*-
# 2020 FinanceData.KR http://financedata.kr fb.com/financedata
import requests
import json
import pandas as pd
try:
from pandas import json_normalize
except ImportError:
from pandas.io.json import json_normalize
def report(api_key, corp_code, key_word, bsns_year, reprt_code='11011'):
key_word_map = {
'증자': 'irdsSttus',
'배당': 'alotMatter',
'자기주식': 'tesstkAcqsDspsSttus',
'최대주주': 'hyslrSttus',
'최대주주변동': 'hyslrChgSttus',
'소액주주': 'mrhlSttus',
'임원': 'exctvSttus',
'직원': 'empSttus',
'임원개인보수': 'hmvAuditIndvdlBySttus',
'임원전체보수': 'hmvAuditAllSttus',
'개인별보수': 'indvdlByPay',
'타법인출자': 'otrCprInvstmntSttus',
}
if key_word not in key_word_map.keys():
raise ValueError('key_word is invalid: you can use one of ', key_word_map.keys())
url = "https://opendart.fss.or.kr/api/{}.json".format(key_word_map[key_word])
params = {
'crtfc_key': api_key, # 인증키
'corp_code': corp_code, # 회사 고유번호
'bsns_year': bsns_year, # 사업년도
'reprt_code': reprt_code, # 보고서 코드 ("11011"=사업보고서)
}
r = requests.get(url, params=params)
jo = json.loads(r.text)
if 'list' not in jo:
return None
return json_normalize(jo, 'list')