Showing
5 changed files
with
141 additions
and
12 deletions
.vscode/launch.json
0 → 100644
| 1 | +{ | ||
| 2 | + // Use IntelliSense to learn about possible attributes. | ||
| 3 | + // Hover to view descriptions of existing attributes. | ||
| 4 | + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
| 5 | + "version": "0.2.0", | ||
| 6 | + "configurations": [ | ||
| 7 | + { | ||
| 8 | + "type": "node", | ||
| 9 | + "request": "launch", | ||
| 10 | + "name": "Launch Program", | ||
| 11 | + "skipFiles": [ | ||
| 12 | + "<node_internals>/**" | ||
| 13 | + ], | ||
| 14 | + "program": "${workspaceFolder}\\test.js" | ||
| 15 | + } | ||
| 16 | + ] | ||
| 17 | +} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
index.html
0 → 100644
| 1 | +<!DOCTYPE html> | ||
| 2 | +<html lang="en"> | ||
| 3 | + | ||
| 4 | +<head> | ||
| 5 | + <meta charset="UTF-8"> | ||
| 6 | + <title>OSW</title> | ||
| 7 | + <link rel="stylesheet" href="/css/style.css" crossorigin="anonymous"> | ||
| 8 | + <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" | ||
| 9 | + integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous"> | ||
| 10 | + <link href="https://fonts.googleapis.com/css?family=Jua&display=swap" rel="stylesheet"> | ||
| 11 | +</head> | ||
| 12 | + | ||
| 13 | +<body> | ||
| 14 | + helloworld | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + <script src="https://code.jquery.com/jquery-3.3.1.min.js" | ||
| 18 | + integrity="sha384-tsQFqpEReu7ZLhBV2VZlAu7zcOV+rXbYlF2cqB8txI/8aZajjp4Bqd+V6D5IgvKT" | ||
| 19 | + crossorigin="anonymous"></script> | ||
| 20 | + <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" | ||
| 21 | + integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" | ||
| 22 | + crossorigin="anonymous"></script> | ||
| 23 | + <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" | ||
| 24 | + integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" | ||
| 25 | + crossorigin="anonymous"></script> | ||
| 26 | +</body> | ||
| 27 | + | ||
| 28 | +</html> | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| ... | @@ -2,30 +2,63 @@ from bs4 import BeautifulSoup | ... | @@ -2,30 +2,63 @@ from bs4 import BeautifulSoup |
| 2 | from urllib.request import urlopen | 2 | from urllib.request import urlopen |
| 3 | import openpyxl | 3 | import openpyxl |
| 4 | import datetime | 4 | import datetime |
| 5 | + | ||
| 5 | # coding = utf-8 | 6 | # coding = utf-8 |
| 6 | -filename = "C://area_code.xlsx" # area_code.xlsx | 7 | + |
| 8 | +filename = "area_code.xlsx" # area_code.xlsx | ||
| 7 | book = openpyxl.load_workbook(filename) | 9 | book = openpyxl.load_workbook(filename) |
| 10 | + | ||
| 8 | sheet = book.worksheets[0] | 11 | sheet = book.worksheets[0] |
| 9 | code = [] | 12 | code = [] |
| 13 | + | ||
| 10 | for cell in sheet['E']: | 14 | for cell in sheet['E']: |
| 11 | code.append(cell.value) | 15 | code.append(cell.value) |
| 12 | -area = input("읍/면/동을 입력(띄어쓰기 없이 입력 - 예:영통3동)\n") | 16 | + |
| 17 | + | ||
| 18 | +sys.stdin.reconfigure(encoding='utf-8') | ||
| 19 | +sys.stdout.reconfigure(encoding='utf-8') | ||
| 20 | +area = input() | ||
| 21 | +print(area) | ||
| 13 | col = code.index(area) | 22 | col = code.index(area) |
| 14 | area_code_index = 'B' + str(col+1) | 23 | area_code_index = 'B' + str(col+1) |
| 15 | area_code = sheet[area_code_index].value | 24 | area_code = sheet[area_code_index].value |
| 16 | #print(area_code) | 25 | #print(area_code) |
| 26 | + | ||
| 17 | now = datetime.datetime.now() | 27 | now = datetime.datetime.now() |
| 18 | nowDate = now.strftime('%Y%m%d') #20191201형태로 연월일 받음 | 28 | nowDate = now.strftime('%Y%m%d') #20191201형태로 연월일 받음 |
| 19 | #print(nowDate) | 29 | #print(nowDate) |
| 30 | + | ||
| 20 | url = "http://newsky2.kma.go.kr/iros/RetrieveLifeIndexService3/getSensorytemLifeList?serviceKey=UwTMv516Y0zIgZCDqzdPtf1jmbv287%2BOn1kqxcZizw8%2Be5OV5UmIc09icqMqSpEMbHOiCWoPK%2BZVD%2Bjbc%2BwgBg%3D%3D&areaNo=" + area_code + "&time=" + nowDate + "03" | 31 | url = "http://newsky2.kma.go.kr/iros/RetrieveLifeIndexService3/getSensorytemLifeList?serviceKey=UwTMv516Y0zIgZCDqzdPtf1jmbv287%2BOn1kqxcZizw8%2Be5OV5UmIc09icqMqSpEMbHOiCWoPK%2BZVD%2Bjbc%2BwgBg%3D%3D&areaNo=" + area_code + "&time=" + nowDate + "03" |
| 32 | + | ||
| 21 | result = urlopen(url) | 33 | result = urlopen(url) |
| 34 | + | ||
| 22 | html = result.read() | 35 | html = result.read() |
| 36 | + | ||
| 23 | soup = BeautifulSoup(html, 'html.parser') | 37 | soup = BeautifulSoup(html, 'html.parser') |
| 38 | + | ||
| 39 | +""" | ||
| 40 | +warm_url="http://newsky2.kma.go.kr/iros/RetrieveLifeIndexService3/getSensoryHeatLifeList?ServiceKey=UwTMv516Y0zIgZCDqzdPtf1jmbv287%2BOn1kqxcZizw8%2Be5OV5UmIc09icqMqSpEMbHOiCWoPK%2BZVD%2Bjbc%2BwgBg%3D%3D&areaNo" + area_code + "&requestCode=A20&time=" + nowDate + "06" | ||
| 41 | + | ||
| 42 | +warm_result = urlopen(url) | ||
| 43 | + | ||
| 44 | +warm_html=result.read() | ||
| 45 | + | ||
| 46 | +warm_soup=BeautifulSoup(warm_html,'html.parser') | ||
| 47 | +warm_hours=["h3","h6","h9","h12","h15","h18","h21"] | ||
| 48 | +sens_temper_warm=[]#더위 체감 지수 | ||
| 49 | +warm_danger=0 #겨울 경우 위험도 | ||
| 50 | +현재 12월 기준으로는 더위 체감 지수는 제공 되고 있지 않다. | ||
| 51 | +""" | ||
| 24 | contents = soup.find("date") | 52 | contents = soup.find("date") |
| 25 | hours = ["h3","h6","h9","h12","h15","h18","h21","h24"] # date의 시간으로부터 n시간 이후의 예측온도 | 53 | hours = ["h3","h6","h9","h12","h15","h18","h21","h24"] # date의 시간으로부터 n시간 이후의 예측온도 |
| 26 | -sens_temper = [] | 54 | +sens_temper = [] #체감온도 |
| 55 | + | ||
| 27 | # 2019120103: 19년 12월 1일 새벽 3시 기준이므로 리스트에는 6시, 9시, ..., 익일 3시까지의 예측 체감온도가 저장됨. | 56 | # 2019120103: 19년 12월 1일 새벽 3시 기준이므로 리스트에는 6시, 9시, ..., 익일 3시까지의 예측 체감온도가 저장됨. |
| 28 | #sens_temper[06시온도,09시온도,12시온도,15시온도,18시온도,21시온도,24시온도,익일03시온도] | 57 | #sens_temper[06시온도,09시온도,12시온도,15시온도,18시온도,21시온도,24시온도,익일03시온도] |
| 58 | + | ||
| 59 | +cold_danger=0 #추울 경우 위험도 숫자가 커질수록 증가 | ||
| 60 | + | ||
| 61 | + | ||
| 29 | for i in range(0, len(hours)): | 62 | for i in range(0, len(hours)): |
| 30 | temper = soup.find(hours[i]) | 63 | temper = soup.find(hours[i]) |
| 31 | sens_temper.append(int(temper.text)) | 64 | sens_temper.append(int(temper.text)) |
| ... | @@ -35,40 +68,55 @@ for i in range(0, len(hours)): | ... | @@ -35,40 +68,55 @@ for i in range(0, len(hours)): |
| 35 | print("익일 03시:", temper.text+"°C") | 68 | print("익일 03시:", temper.text+"°C") |
| 36 | else: | 69 | else: |
| 37 | print(str(int(hours[i][1:])+3)+"시:", temper.text+"°C") | 70 | print(str(int(hours[i][1:])+3)+"시:", temper.text+"°C") |
| 38 | -if max(sens_temper) <= 5: | 71 | + |
| 39 | - if min(sens_temper) >= -5 and min(sens_temper) <=0: | 72 | +if max(sens_temper) <= 8: |
| 73 | + if min(sens_temper) >= -3 and min(sens_temper) <=2: | ||
| 40 | print("패딩, 겨울야상, 양털자켓, 폴라티, 니트, 기모바지") | 74 | print("패딩, 겨울야상, 양털자켓, 폴라티, 니트, 기모바지") |
| 41 | print("쌀쌀한 날씨입니다. 생각보다 추워요!") | 75 | print("쌀쌀한 날씨입니다. 생각보다 추워요!") |
| 42 | - elif min(sens_temper) < -5: | 76 | + cold_danger=1 |
| 77 | + elif min(sens_temper) < -3 and min(sens_temp)>=-10: | ||
| 43 | print("패딩, 겨울야상, 양털자켓, 폴라티, 니트, 기모바지") | 78 | print("패딩, 겨울야상, 양털자켓, 폴라티, 니트, 기모바지") |
| 44 | print("마스크, 목도리, 장갑을 착용하세요!") | 79 | print("마스크, 목도리, 장갑을 착용하세요!") |
| 45 | - if min(sens_temper) < -10: | 80 | + cold_danger=2 |
| 46 | - print("외출을 자제하는 것이 좋겠습니다!") | 81 | + if min(sens_temper) < -10and min(sens_temper)>=-15: |
| 47 | - elif min(sens_temper) > 0: | 82 | + print("피부를 되도록 노출하지 마세요") |
| 83 | + print("최대한 따뜻하게 입고 다니세요") | ||
| 84 | + cold_danger=3 | ||
| 85 | + elif (min(sens_temper)<-15): | ||
| 86 | + print("외출을 자제해 주세요") | ||
| 87 | + print("외출시 내복 및 옷을 겹겹이 입어 주시고 많이 움직여 주세요") | ||
| 88 | + cold_danger=4 | ||
| 89 | + elif min(sens_temper) > 2: | ||
| 48 | print("패딩, 겨울야상, 양털자켓, 폴라티, 니트, 기모바지, 스타킹") | 90 | print("패딩, 겨울야상, 양털자켓, 폴라티, 니트, 기모바지, 스타킹") |
| 49 | - print("0도를 웃도는 날씨네요. 외투 안에는 가벼운 옷을 추천해요!") | 91 | + print("외투 안에는 가벼운 옷을 추천해요!") |
| 50 | 92 | ||
| 51 | 93 | ||
| 52 | -if max(sens_temper) >= 6 and max(sens_temper) <= 9: | 94 | +if max(sens_temper) >= 8 and max(sens_temper) <= 13: |
| 53 | print("코트, 가죽자켓, 맨투맨, 티셔츠(사계절), 바지(사계절)") | 95 | print("코트, 가죽자켓, 맨투맨, 티셔츠(사계절), 바지(사계절)") |
| 54 | if min(sens_temper) < 3: | 96 | if min(sens_temper) < 3: |
| 55 | print("일교차에 유의하세요! 추위에 약한 분들은 외투 하나 더 챙기세요!") | 97 | print("일교차에 유의하세요! 추위에 약한 분들은 외투 하나 더 챙기세요!") |
| 56 | -elif max(sens_temper) >= 10 and max(sens_temper) <= 11: | 98 | + |
| 99 | +elif max(sens_temper) >= 13 and max(sens_temper) <= 15: | ||
| 57 | print("트렌치코트, 간절기 야상, 후드티, 여러겹 레이어드") | 100 | print("트렌치코트, 간절기 야상, 후드티, 여러겹 레이어드") |
| 58 | if min(sens_temper) < 5: | 101 | if min(sens_temper) < 5: |
| 59 | print("일교차에 유의하세요! 추위에 약한 분들은 외투 하나 더 챙기세요!") | 102 | print("일교차에 유의하세요! 추위에 약한 분들은 외투 하나 더 챙기세요!") |
| 103 | + | ||
| 60 | elif max(sens_temper) >= 12 and max(sens_temper) <= 16: | 104 | elif max(sens_temper) >= 12 and max(sens_temper) <= 16: |
| 61 | print("자켓, 셔츠, 가디건, 후드(사계절)") | 105 | print("자켓, 셔츠, 가디건, 후드(사계절)") |
| 62 | if min(sens_temper) < 6: | 106 | if min(sens_temper) < 6: |
| 63 | print("일교차에 유의하세요! 추위에 약한 분들은 외투 하나 더 챙기세요!") | 107 | print("일교차에 유의하세요! 추위에 약한 분들은 외투 하나 더 챙기세요!") |
| 108 | +""" | ||
| 64 | elif max(sens_temper) >= 17 and max(sens_temper) <= 19: | 109 | elif max(sens_temper) >= 17 and max(sens_temper) <= 19: |
| 65 | print("가디건, 니트, 맨투맨, 후드티, 면바지, 슬랙스, 원피스") | 110 | print("가디건, 니트, 맨투맨, 후드티, 면바지, 슬랙스, 원피스") |
| 66 | if min(sens_temper) < 9: | 111 | if min(sens_temper) < 9: |
| 67 | print("일교차에 유의하세요! 얇은 외투 챙겨가세요!") | 112 | print("일교차에 유의하세요! 얇은 외투 챙겨가세요!") |
| 113 | + | ||
| 68 | elif max(sens_temper) >= 20 and max(sens_temper) <= 22: | 114 | elif max(sens_temper) >= 20 and max(sens_temper) <= 22: |
| 69 | print("긴팔티, 후드티, 면바지, 슬랙스") | 115 | print("긴팔티, 후드티, 면바지, 슬랙스") |
| 70 | if min(sens_temper) < 11: | 116 | if min(sens_temper) < 11: |
| 71 | print("일교차에 유의하세요! 얇은 외투 챙겨가세요!") | 117 | print("일교차에 유의하세요! 얇은 외투 챙겨가세요!") |
| 118 | + | ||
| 72 | elif max(sens_temper) >= 23 and max(sens_temper) <= 26: | 119 | elif max(sens_temper) >= 23 and max(sens_temper) <= 26: |
| 73 | print("반팔티, 얇은 셔츠, 얇은 긴팔티, 반바지, 면바지") | 120 | print("반팔티, 얇은 셔츠, 얇은 긴팔티, 반바지, 면바지") |
| 74 | 121 | ||
| 122 | +""" | ... | ... |
test.js
0 → 100644
| 1 | +var http = require('http'); | ||
| 2 | +var fs = require('fs'); | ||
| 3 | +var app = http.createServer(function(request,response){ | ||
| 4 | + var url = request.url; | ||
| 5 | + if(request.url == '/'){ | ||
| 6 | + url = '/index.html'; | ||
| 7 | + } | ||
| 8 | + if(request.url == '/favicon.ico'){ | ||
| 9 | + response.writeHead(404); | ||
| 10 | + response.end(); | ||
| 11 | + return; | ||
| 12 | + } | ||
| 13 | + response.writeHead(200); | ||
| 14 | + response.end(fs.readFileSync(__dirname + url)); | ||
| 15 | + | ||
| 16 | +}); | ||
| 17 | +app.listen(3000); | ||
| 18 | + | ||
| 19 | +const {PythonShell} = require('python-shell'); | ||
| 20 | + | ||
| 21 | +var options = { | ||
| 22 | + mode: 'text', | ||
| 23 | + pythonOptions: ['-u'], | ||
| 24 | + scriptPath: '', | ||
| 25 | + encoding: 'utf8', | ||
| 26 | + args: ["영통1동"] | ||
| 27 | +}; | ||
| 28 | + | ||
| 29 | +var arr; | ||
| 30 | +var test = new PythonShell('recommend_clothes.py', options); | ||
| 31 | +var data='영통1동'; | ||
| 32 | +test.send(data); | ||
| 33 | +test.on('message',function(message){ | ||
| 34 | + arr = message.split(' '); | ||
| 35 | +}) | ||
| 36 | + |
~$area_code.xlsx
0 → 100644
No preview for this file type
-
Please register or login to post a comment