1
1
import os
2
2
import json
3
+ import requests
3
4
import pandas as pd
4
5
5
6
_path = os .path .dirname (__file__ )
6
7
_project_root_path = os .path .dirname (_path )
7
- _code_bdong_json_path = f"""{ _project_root_path } /raw/code_bdong.json"""
8
- _code_hdong_json_path = f"""{ _project_root_path } /raw/code_hdong.json"""
9
- _code_hdong_bdong_json_path = f"""{ _project_root_path } /raw/code_hdong_bdong.json"""
10
8
_code_vworld_json_path = f"""{ _project_root_path } /raw/code_vworld.json"""
11
9
10
+ _code_hdong_json_url = "https://raw.githubusercontent.com/WooilJeong/code/main/code/code_dong/code_hdong.json"
11
+ _code_hdong_bdong_json_url = "https://raw.githubusercontent.com/WooilJeong/code/main/code/code_dong/code_hdong_bdong.json"
12
12
13
- CODE_INFORMATION = F"""\
14
- 출처: 행정기관(행정동) 및 관할구역(법정동) 변경내역(2023. 5. 1. 시행)
15
- URL: https://www.mois.go.kr/frt/bbs/type001/commonSelectBoardArticle.do?bbsId=BBSMSTR_000000000052&nttId=100215
16
- """
13
+ def get_code_dong_by_url (url ):
14
+ """
15
+ URL로 동 코드 JSON 읽기
16
+ """
17
+ res = requests .get (url )
18
+ return res .json ()
17
19
18
20
19
21
def read_json_file (file_path ):
@@ -29,25 +31,31 @@ def code_bdong():
29
31
"""
30
32
법정동코드(실제주소) 데이터 반환
31
33
"""
32
- print (CODE_INFORMATION )
33
- return pd .DataFrame (read_json_file (_code_bdong_json_path )).fillna ("" )
34
-
34
+ res = get_code_dong_by_url (_code_bdong_json_url )
35
+ name = res ['name' ]
36
+ data = res ['data' ]
37
+ print (f"출처: { name } " )
38
+ return pd .DataFrame (data ).fillna ("" )
35
39
36
40
def code_hdong ():
37
41
"""
38
42
행정기관코드(행정동) 데이터 반환
39
43
"""
40
- print (CODE_INFORMATION )
41
- return pd .DataFrame (read_json_file (_code_hdong_json_path )).fillna ("" )
42
-
44
+ res = get_code_dong_by_url (_code_hdong_json_url )
45
+ name = res ['name' ]
46
+ data = res ['data' ]
47
+ print (f"출처: { name } " )
48
+ return pd .DataFrame (data ).fillna ("" )
43
49
44
50
def code_hdong_bdong ():
45
51
"""
46
52
행정기관코드 + 관할 법정동코드 데이터 반환
47
53
"""
48
- print (CODE_INFORMATION )
49
- return pd .DataFrame (read_json_file (_code_hdong_bdong_json_path )).fillna ("" )
50
-
54
+ res = get_code_dong_by_url (_code_hdong_bdong_json_url )
55
+ name = res ['name' ]
56
+ data = res ['data' ]
57
+ print (f"출처: { name } " )
58
+ return pd .DataFrame (data ).fillna ("" )
51
59
52
60
def get_vworld_data_api_info_by_dataframe ():
53
61
"""
0 commit comments