본문 바로가기

Data Science/Data Collection

[04. 금융감독원 API] 011. 사업보고서 주요정보 – 직원 현황

728x90

직원 현황 API 코드를 작성해보자.

 

[그림 4.11] 직원 현황 개발가이드

 

import json
import pandas as pd
import requests

def get_employee(api_key, code, year, report_code):
    fullUrl = 'https://opendart.fss.or.kr/api/empSttus.json?crtfc_key=%s&corp_code=%s&' \
              'bsns_year=%s&reprt_code=%s' % (api_key, code, year, report_code)

    response = requests.get(fullUrl, headers={'User-Agent': 'Mozilla/5.0'})
    result = response.text
    result = json.loads(result)

    if result['status'] == '000':
        data = pd.DataFrame(result['list'])

        return data

if __name__ == '__main__':
    api_key ='*'
    code = '00126380'
    year = '2018'
    report_code = '11011'

    employee = get_employee(api_key, code, year, report_code)
    print(employee)


결과 값
      rcept_no    corp_cls  ... fyer_salary_totamt jan_salary_am
0  20190401004781        Y  ...                  -             -
1  20190401004781        Y  ...  2,315,671,000,000    93,000,000
2  20190401004781        Y  ...                  -             -
3  20190401004781        Y  ...                  -             -
4  20190401004781        Y  ...                  -             -
5  20190401004781        Y  ...                  -             -
6  20190401004781        Y  ...                  -             -
7  20190401004781        Y  ...                  -             -
8  20190401004781        Y  ...                  -             -
9  20190401004781        Y  ...  9,444,207,000,000   128,000,000
728x90