Skip to content

Instantly share code, notes, and snippets.

@NeedPainkiller
Last active March 16, 2019 09:29
Show Gist options
  • Save NeedPainkiller/77b8d6555d76422247a2cb00d5020516 to your computer and use it in GitHub Desktop.
Save NeedPainkiller/77b8d6555d76422247a2cb00d5020516 to your computer and use it in GitHub Desktop.
import sys
import requests
import xml.etree.ElementTree as ElementTree
PostUrl = "https://teht.hometax.go.kr/wqAction.do?actionId=ATTABZAA001R08&screenId=UTEABAAA13&popupYn=false&realScreenId="
XmlRaw = "<map id=\"ATTABZAA001R08\"><pubcUserNo/><mobYn>N</mobYn><inqrTrgtClCd>1</inqrTrgtClCd><txprDscmNo>\{CRN\}</txprDscmNo><dongCode>15</dongCode><psbSearch>Y</psbSearch><map id=\"userReqInfoVO\"/></map>"
def call(crn):
res = requests.post(PostUrl, data=XmlRaw.replace("\{CRN\}", crn), headers={'Content-Type': 'text/xml'})
xml = ElementTree.fromstring(res.text).findtext("trtCntn")
result = crn + "\t" + xml.replace("\n","").replace("\t", " ") + "\n"
return result
inputs = open('./list.txt', 'r', encoding='UTF8')
result = ''
for line in inputs:
result += call(line.strip())
inputs.close()
outputs = open('./output.txt', 'w', encoding='UTF8')
outputs.write(result)
outputs.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment