-
Notifications
You must be signed in to change notification settings - Fork 2
/
getdata.py
89 lines (71 loc) · 2.49 KB
/
getdata.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import secrets
import requests
from urllib.parse import urlencode, quote_plus
from django.conf import settings
# 전체 num : 2649
# API_KEY = getattr("secrets.json", "CAMP_API_KEY")
def get_data():
url = "http://api.visitkorea.or.kr/openapi/service/rest/GoCamping/basedList"
queryParams = '?' + urlencode({quote_plus(
'numOfRows'): '2649',
quote_plus('MobileOS'): 'AND',
quote_plus('MobileApp'): 'Carping',
quote_plus('_type'): 'json',
quote_plus('ServiceKey'): ""}) + API_KEY
req = requests.get(url + queryParams)
req_json = req.json()
response = req_json['response']
body = response['body']
items = body['items']
item = items['item']
return item
# CampSite
# for item in item:
item = get_data()
# 26개
column = ['name', 'lat', 'lon' 'animal', 'event', 'program', 'website', 'phone', 'address', 'brazier', 'oper_day', 'off_day_start',
'off_day_end', 'faculty', 'permission_date', 'reservation', 'toilet', 'shower', 'type', 'sub_facility', 'season', 'image', 'area', 'themenv', 'created_at', 'updated_at']
# 27개
json_column = ['facltNm', 'mapX', 'mapY', 'animalCmgCl', 'clturEvent', 'exprnProgrm', 'homepage', 'tel', 'addr1',
'brazierCl', 'operDeCl', 'hvofBgnde', 'hvofEnddle', 'facltDivNm', 'prmisnDe', 'resveCl', 'toiletCo', 'swrmCo', 'induty', 'sbrsCl', 'sbrsEtc', 'operPdCl', 'firstImageUrl', 'doNm', 'themaEnvrnCl', 'createdtime', 'modifiedtime']
# data = []
# for i in range(22):
# data.append(0)
# for i in item:
# # 0 ~ 21
# for json_num in range(len(json_column)):
# if not i.get(json_column[json_num]) == None:
# data[json_num] += 1
count = 0
for i in item:
key = i.get("facltNm")
# print(key)
if key == "태안라온캠핑장 ":
print(i.get("induty"))
print(i.get("gnrlSiteCo"))
print(i.get("autoSiteCo"))
print(i.get("glampSiteCo"))
print(i.get("caravSiteCo"))
print(i.get("indvdlCaravSiteCo"))
"""
Categorize
"""
# item_arr = []
# for i in item:
# key = i.get('induty')
# if key is not None:
# i_arr = key.split(',')
# for j in i_arr:
# if not j in item_arr:
# item_arr.append(j)
# count += 1
# if '자동차야영장' in i_arr:
# count += 1
# if induty == "공동취사장":
# count += 1xz
# print(induty)
# print(item_arr)
print(count)
#위도 : x
#경도 : y
# 이름, 주소, 위도, 경도, asㅁㄴxaxAxA, 화로여부, 웹사이트 주소,