-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreceive_data_api.py
33 lines (26 loc) · 1021 Bytes
/
receive_data_api.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import os
# from urllib2 import Request, urlopen
# from urllib import urlencode, quote_plus
from dotenv import load_dotenv
load_dotenv()
API_KEY = os.getenv("key")
print(API_KEY)
# Government OpenAPI Information: https://www.data.go.kr/tcs/dss/selectApiDataDetailView.do?publicDataPk=15043376
# Seoul City OpenAPI Information: http://data.seoul.go.kr/dataList/OA-20279/S/1/datasetView.do;jsessionid=EF730F0453C4F306BF7C15516BA71528.new_portal-svr-11
# API Key admin page: https://data.go.kr/iim/api/selectAPIAcountView.do
url = "http://openapi.data.go.kr/openapi/service/rest/Covid19/getCovid19InfStateJson"
"""
queryParams = "?" + urlencode(
{
quote_plus("ServiceKey"): "서비스키",
quote_plus("pageNo"): "1",
quote_plus("numOfRows"): "10",
quote_plus("startCreateDt"): "20200310",
quote_plus("endCreateDt"): "20201226",
}
)
request = Request(url + queryParams)
request.get_method = lambda: "GET"
response_body = urlopen(request).read()
print(response_body)
"""