Created
December 4, 2017 17:07
-
-
Save mr-yoo/48f994ccf7f736f15dd3d3310b0e107f to your computer and use it in GitHub Desktop.
미래에셋대우 - 2기
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import xml.etree.ElementTree as ET | |
# ---------------------------------------------------------------------------- | |
# Step 1. 페이지 스크랩핑 | |
xml = """<?xml version="1.0" encoding="utf-8"?> | |
<message> | |
<proframeHeader> | |
<pfmAppName>FS-DIS2</pfmAppName> | |
<pfmSvcName>DISDlsOfferSO</pfmSvcName> | |
<pfmFnName>selectSubscribing</pfmFnName> | |
</proframeHeader> | |
<systemHeader></systemHeader> | |
<DISDlsDTO> | |
<val1></val1> | |
<val2></val2> | |
<val3></val3> | |
<val4></val4> | |
<val5></val5> | |
<val6>0</val6> | |
</DISDlsDTO> | |
</message>""" | |
url = "http://dis.kofia.or.kr/proframeWeb/XMLSERVICES" | |
response = requests.post(url, data=xml).text | |
# ---------------------------------------------------------------------------- | |
# Step 2. 다운로드 파일 이름 추출 | |
tree = ET.fromstring(response) | |
file_names = tree.findall('message/DISDlsListDTO/DISDlsDTO/originalFileNm') | |
# ---------------------------------------------------------------------------- | |
# Step 3. PDF 다운로드 | |
url = "http://disdown.kofia.or.kr/COMFSFileDownload.jsp" | |
for file in file_names: | |
param = { | |
"serverFileNm": "1e8761fba739f672-562c860e15e785ef6f01b31.pdf", | |
"serverPath": "/fsfile/report/receipt", | |
"filename": file.text, | |
} | |
r = requests.get(url, params=param).content | |
with open(file.text, 'wb') as f: | |
f.write(r) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment