Loading...
Loading...
Look up a Korean postcode from a known address with the official ePost road-name search page. Use when the user knows the address but wants the postal code quickly.
npx skill4agent add nomadamas/k-skill zipcode-searchcurlpython3https://parcel.epost.go.kr/parcel/comm/zipcode/comm_newzipcd_list.jspkeywordpython3urllibcurl --http1.1 --tls-max 1.2python3 - <<'PY'
import html
import re
import subprocess
query = "세종대로 209"
cmd = [
"curl",
"--http1.1",
"--tls-max",
"1.2",
"--silent",
"--show-error",
"--location",
"--retry",
"3",
"--retry-all-errors",
"--retry-delay",
"1",
"--max-time",
"20",
"--get",
"--data-urlencode",
f"keyword={query}",
"https://parcel.epost.go.kr/parcel/comm/zipcode/comm_newzipcd_list.jsp",
]
result = subprocess.run(
cmd,
check=True,
capture_output=True,
text=True,
encoding="utf-8",
)
page = result.stdout
matches = re.findall(
r'name="sch_zipcode"\s+value="([^"]+)".*?name="sch_address1"\s+value="([^"]+)".*?name="sch_bdNm"\s+value="([^"]*)"',
page,
re.S,
)
if not matches:
raise SystemExit("검색 결과가 없습니다.")
for zip_code, address, building in matches[:5]:
suffix = f" ({building})" if building else ""
print(f"{zip_code}\t{html.unescape(address)}{suffix}")
PYsch_zipcodesch_address1sch_bdNmtimeoutcurl--max-time--retry세종대로 209서울 종로구 세종대로 209세종대로 209서울 종로구 세종대로 209세종로 209mktemp| headcurl: (23)sch_zipcodecurlurllib