https://opendart.fss.or.kr/guide/detail.do?apiGrpCd=DS002&apiId=2019011 

 

전자공시 OPENDART 시스템 | 개발가이드 | 상세

사업보고서 주요정보 개발가이드 사업보고서 주요정보 직원 현황 직원 현황 개발가이드 기본 정보 기본 정보 메서드 요청URL 인코딩 출력포멧 GET https://opendart.fss.or.kr/api/empSttus.json UTF-8 JSON GET htt

opendart.fss.or.kr

 

# -*- coding: utf-8 -*-

# OpenDartAPI
# - https://opendart.fss.or.kr/guide/detail.do?apiGrpCd=DS002&apiId=2019011
# - 사업보고서 주요내용 : 직원현황 정보

import xml.etree.ElementTree as ET

import requests


class ClassAPI_empStatus:
    def __init__(self):
        self.apiKey = "-----------------------------------------------"
        self.apiUrl = ""
        self.corp_code = ""
        self.bsns_year = ""
        self.reprt_code = ""

    def set_api_url(self):
        url = "https://opendart.fss.or.kr/api/empSttus.xml"
        url = url + "?crtfc_key=" + self.apiKey
        url = url + "&corp_code=" + self.corp_code
        url = url + "&bsns_year=" + self.bsns_year
        url = url + "&reprt_code=" + self.reprt_code
        self.apiUrl = url
        return url

    def call_api(self):
        self.set_api_url()
        response = requests.get(self.apiUrl)
        ### http 통신 결과 코드 확인
        # print("response.status_code : " + str(response.status_code))
        ## http 요청이 성공했을때 API의 리턴값을 가져옵니다.
        if response.status_code == 200:
            rtnString = response.text

        return rtnString


if __name__ == '__main__':
    Obj = ClassAPI_empStatus()

    # 대상기업 : 삼성전자
    Obj.corp_code = "00126380"

    # 대상연도 : 2021
    Obj.bsns_year = "2021"

    # 보고서종류 : 년간사업보고서
    Obj.reprt_code = "11011"

    Obj.call_api()

    tree = ET.fromstring(Obj.call_api())
    ET.dump(tree)
    for row in tree.iter("list"):
        if str(row.find('fo_bbm').text) == "성별합계":
            print("-----------------------------------------------------------------------------------------------")
            print("접수번호:" + str(row.find('rcept_no').text))
            print("법인구분 : Y(유가), K(코스닥), N(코넥스), E(기타):" + str(row.find('corp_cls').text))
            print("공시대상회사의 고유번호(8자리):" + str(row.find('corp_code').text))
            print("법인명:" + str(row.find('corp_name').text))
            print("성별 남, 여:" + str(row.find('sexdstn').text))
            print("사업부문:" + str(row.find('fo_bbm').text))
            print("개정 전 직원 수 정규직:" + str(row.find('reform_bfe_emp_co_rgllbr').text))
            print("개정 전 직원 수 계약직:" + str(row.find('reform_bfe_emp_co_cnttk').text))
            print("개정 전 직원 수 기타:" + str(row.find('reform_bfe_emp_co_etc').text))
            print("정규직 수	상근, 비상근:" + str(row.find('rgllbr_co').text))
            print("정규직 단시간 근로자 수	대표이사, 이사, 사외이사 등:" + str(row.find('rgllbr_abacpt_labrr_co').text))
            print("계약직 수:" + str(row.find('cnttk_co').text))
            print("계약직 단시간 근로자 수:" + str(row.find('cnttk_abacpt_labrr_co').text))
            print("합계:" + str(row.find('sm').text))
            print("평균 근속 연수:" + str(row.find('avrg_cnwk_sdytrn').text))
            print("연간 급여 총액:" + str(row.find('fyer_salary_totamt').text))
            print("1인평균 급여 액:" + str(row.find('jan_salary_am').text))