Created
December 5, 2017 15:38
-
-
Save mr-yoo/81574873dc8cdecfd380ad3765d04c51 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 | |
from openpyxl import Workbook | |
# ---------------------------------------------------------------------------- | |
# 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. 엑셀 write | |
wb = Workbook() | |
ws = wb.worksheets[0] | |
# HEADER (First Line) | |
ws.append(["발행회사", "신용등급", "상품명", "기초자산"]) | |
for entity in ET.fromstring(response).iter('DISDlsDTO'): | |
ws.append([entity[3].text, entity[4].text, entity[5].text, entity[7].text]) | |
wb.save('test.xlsx') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
entity[3] : 발행회사
entity[4] : 신용등급
entity[5] : 상품명
entity[7] : 기초자산
entity[25] : 발행일
entity[13] : 만기일
entity[14] : 제시수익률
entity[15] : 청약시작일
entity[16] : 청약종료일
entity[17] : 상품유형
entity[19] : 홈페이지
entity[20] : 비고