-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
38 lines (30 loc) · 982 Bytes
/
main.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
#!/usr/bin/env python3
import requests
import datetime
import os, sys
import dotenv
dotenv_file = dotenv.find_dotenv()
dotenv.load_dotenv(dotenv_file)
now = datetime.datetime.now()
formattedDate = now.strftime("%Y%m%d")
url = "https://open.neis.go.kr/hub/mealServiceDietInfo"
params = {
'KEY': os.environ['API_KEY'],
'Type': "json",
'pIndex': 1,
'pSize': 5,
'ATPT_OFCDC_SC_CODE': os.environ['ATPT_OFCDC_SC_CODE'], # 시도교육청코드
'SD_SCHUL_CODE': os.environ['SD_SCHUL_CODE'], # 표준학교코드
'MLSV_YMD': formattedDate
}
res = requests.get(url, params=params)
print(formattedDate)
data: dict = res.json()['mealServiceDietInfo']
head: list = data[0]['head']
rows: list = data[1]['row']
print(rows)
for row in rows:
if row['MMEAL_SC_NM'] == sys.argv[1]:
data = row['DDISH_NM'].replace('<br/>', '\n')
os.system(f'termux-notification -t 급식 -c "{data}" --icon restaurant')
break