Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test1 #1

Open
KyeongzowD opened this issue Sep 22, 2022 · 0 comments
Open

test1 #1

KyeongzowD opened this issue Sep 22, 2022 · 0 comments

Comments

@KyeongzowD
Copy link
Owner

import os
from urllib.request import urlopen
from io import BytesIO
import zipfile
from pandas import DataFrame as pd
import dart_fss as dart
from datetime import datetime, timedelta
import re
import OpenDartReader
import requests
import json
import urllib

try:
from pandas import json_normalize
except ImportError:
from pandas.io.json import json_normalize

#날짜, 시간에 대한 변수
now = datetime.now()#2022-09-21 11:35:02
before_one_week = now - timedelta(weeks=1)#2022-09-14 11:35:02
bedate=re.sub(r'[^0-9]', '', str(before_one_week))#20220914113502
bedate=bedate[:8]#20220914

api_key=''
dart.set_api_key(api_key=api_key)
url="https://opendart.fss.or.kr/api/list.json?crtfc_key="+api_key+"&bgn_de="+bedate+"&corp_cls=Y"

RLT=urllib.request.urlopen(url)#url에서의 요청 내용 불러오기
D=RLT.read().decode("utf-8")#uft-8==인코딩
#D는 정보를 가지고 있는 url을 읽은 dept 파일
D1=json.loads(D)

recept_no=D1['list'][0]['rcept_no']#고유번호

#공시서류원본파일 url
DNurl="https://opendart.fss.or.kr/api/document.xml?crtfc_key=(K)&rcept_no=recep_no)".foramt(K=api_key,recept_no=recept_no)
urllib.request.urlretrieve(DNurl,"dart_downloadfile.zip")

#zipfile 다운로드
with zipfile.ZipFile("dart_downloadfile.zip","r") as zip_ref:
zip_ref.extractall()

#zip파일 풀기

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant