ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • [Python] 10년치 재무정보 가져오기
    시스템 트레이딩 2017. 4. 5. 21:23

    아래 블로그에서 10년치 재무정보를 R로 가져오는 것을 보고 이것을 python에서 받아올 수 있도록 변형해 보았습니다. 

    http://blog.naver.com/PostView.nhn?blogId=opop4615&logNo=220926349250&parentCategoryNo=57&categoryNo=58&viewDate=&isShowPopularPosts=false&from=postView


    재무정보는 기업정보 제공업체인 세종기업데이터 홈페이지 'sejongdata.co.k'r 에서 제공해주고 있습니다. 

    위 홈페이지의 정보제공 페이지에서 pandas 라이브러리를 이용해서 크롤링 한 것입니다.

    결과는 pandas의 Dataframe 형식으로 저장됩니다. 


    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    # -*- coding: utf-8 -*-
    import pandas as pd
    import html5lib
     
    def EnterpriseInformationCrawler(code):
        # Website Address
        table_address = "http://www.sejongdata.com/business_include_fr/table_main0_bus_01.html?&no="
        table_url = table_address + code
     
        # read html
        total_table = pd.read_html(table_url, encoding='utf8', skiprows=0, header=0, index_col=0)
     
        # merge table
        table_A = total_table[1]
        table_B = total_table[4].drop(total_table[4].index[6])
        table = pd.concat([table_A, table_B])
        print(table)
     
    if __name__ == '__main__':
        EnterpriseInformationCrawler('000020')
     
    cs



    위 블로그의 결과처럼 저장됩니다.









Designed by Tistory.