Seokjin

[UPDATE]clothesRecommendation

Showing 27 changed files with 54 additions and 8 deletions
1 +var request = require('request');
2 +
3 +var url = 'http://apis.data.go.kr/1360000/VilageFcstInfoService_2.0/getUltraSrtNcst';
4 +var queryParams = '?' + encodeURIComponent('serviceKey') + '=3OcUyvx97Vx2YikiZ9IHyRQ6suapku7Xn8VlefQKQWrGIFOGaejhbevwagcubdHfSiQAqJwCV5lyIutw0%2BsppA%3D%3D'; /* Service Key*/
5 +queryParams += '&' + encodeURIComponent('pageNo') + '=' + encodeURIComponent('1'); /* */
6 +queryParams += '&' + encodeURIComponent('numOfRows') + '=' + encodeURIComponent('1000'); /* */
7 +queryParams += '&' + encodeURIComponent('dataType') + '=' + encodeURIComponent('JSON'); /* */
8 +queryParams += '&' + encodeURIComponent('base_date') + '=' + encodeURIComponent('20220605'); /* */
9 +queryParams += '&' + encodeURIComponent('base_time') + '=' + encodeURIComponent('0600'); /* */
10 +queryParams += '&' + encodeURIComponent('nx') + '=' + encodeURIComponent('55'); /* */
11 +queryParams += '&' + encodeURIComponent('ny') + '=' + encodeURIComponent('127'); /* */
12 +
13 +request({
14 + url: url + queryParams,
15 + method: 'GET'
16 +}, function (error, response, body) {
17 + //console.log('Status', response.statusCode);
18 + //console.log('Headers', JSON.stringify(response.headers));
19 + console.log('Reponse received', body);
20 +});
...\ No newline at end of file ...\ No newline at end of file
...@@ -13,4 +13,11 @@ ...@@ -13,4 +13,11 @@
13 자켓:https://www.musinsa.com/app/goods/2594389 13 자켓:https://www.musinsa.com/app/goods/2594389
14 가디건:https://www.musinsa.com/app/goods/1139192/0 14 가디건:https://www.musinsa.com/app/goods/1139192/0
15 청자켓:https://www.musinsa.com/app/goods/1790382 15 청자켓:https://www.musinsa.com/app/goods/1790382
16 -트렌치코트:https://www.musinsa.com/app/goods/2594302
...\ No newline at end of file ...\ No newline at end of file
16 +트렌치코트:https://www.musinsa.com/app/goods/2594302
17 +핫팬츠:https://www.musinsa.com/app/goods/948562
18 +조거팬츠:https://www.musinsa.com/app/goods/948562
19 +롱스커트:https://www.musinsa.com/app/goods/2287458
20 +패딩:https://www.musinsa.com/app/goods/1616798
21 +가죽자켓:https://www.musinsa.com/app/goods/1758197
22 +기모옷:https://www.musinsa.com/app/goods/1718829
23 +울코트:https://www.musinsa.com/app/goods/722573
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -7,8 +7,8 @@ let app = express(); ...@@ -7,8 +7,8 @@ let app = express();
7 app.use(cors()); 7 app.use(cors());
8 8
9 let logid=null; 9 let logid=null;
10 -//const uri = 'mongodb+srv://sjieu17:tjrwls147714@cluster0.lc6pe.mongodb.net/weather_briefing?retryWrites=true&w=majority'; 10 +const uri = 'mongodb://sjieu17:tjrwls147714@cluster0-shard-00-00.lc6pe.mongodb.net:27017,cluster0-shard-00-01.lc6pe.mongodb.net:27017,cluster0-shard-00-02.lc6pe.mongodb.net:27017/?ssl=true&replicaSet=atlas-q8oxwv-shard-0&authSource=admin&retryWrites=true&w=majority';
11 -const uri = 'mongodb+srv://tahmkench:dkrldnsl7@cluster0.vzipl.mongodb.net/?retryWrites=true&w=majority'; 11 +// const uri = 'mongodb+srv://tahmkench:dkrldnsl7@cluster0.vzipl.mongodb.net/?retryWrites=true&w=majority';
12 12
13 let db = mongoose.connect(uri, (err) => { 13 let db = mongoose.connect(uri, (err) => {
14 if (err) { 14 if (err) {
......
...@@ -17,6 +17,8 @@ var url = 'http://apis.data.go.kr/1360000/VilageFcstInfoService_2.0/getVilageFcs ...@@ -17,6 +17,8 @@ var url = 'http://apis.data.go.kr/1360000/VilageFcstInfoService_2.0/getVilageFcs
17 var queryParams = '?' + encodeURIComponent('serviceKey') + '=3OcUyvx97Vx2YikiZ9IHyRQ6suapku7Xn8VlefQKQWrGIFOGaejhbevwagcubdHfSiQAqJwCV5lyIutw0%2BsppA%3D%3D'; /* Service Key*/ 17 var queryParams = '?' + encodeURIComponent('serviceKey') + '=3OcUyvx97Vx2YikiZ9IHyRQ6suapku7Xn8VlefQKQWrGIFOGaejhbevwagcubdHfSiQAqJwCV5lyIutw0%2BsppA%3D%3D'; /* Service Key*/
18 18
19 //오늘의 날짜 구하기 19 //오늘의 날짜 구하기
20 +let base;
21 +
20 let today=new Date(); 22 let today=new Date();
21 let CurDay=today.getFullYear().toString(); 23 let CurDay=today.getFullYear().toString();
22 if(today.getMonth()<9){ 24 if(today.getMonth()<9){
...@@ -26,12 +28,14 @@ else{ ...@@ -26,12 +28,14 @@ else{
26 CurDay+=(today.getMonth()+1).toString(); 28 CurDay+=(today.getMonth()+1).toString();
27 } 29 }
28 if(today.getDate()<10){ 30 if(today.getDate()<10){
31 + base=CurDay+"0"+(today.getDate()-1).toString();
29 CurDay+="0"+today.getDate().toString(); 32 CurDay+="0"+today.getDate().toString();
30 } 33 }
31 else{ 34 else{
35 + base=CurDay+(today.getDate()-1).toString();
32 CurDay+=today.getDate().toString(); 36 CurDay+=today.getDate().toString();
33 } 37 }
34 - 38 +console.log(base);
35 //nx,ny구하기 39 //nx,ny구하기
36 const xlsx=require('xlsx') 40 const xlsx=require('xlsx')
37 const excel=xlsx.readFile('location.xlsx'); 41 const excel=xlsx.readFile('location.xlsx');
...@@ -62,8 +66,8 @@ app.post('/api/weather',(req,res)=>{ ...@@ -62,8 +66,8 @@ app.post('/api/weather',(req,res)=>{
62 queryParams += '&' + encodeURIComponent('pageNo') + '=' + encodeURIComponent('1'); /* */ 66 queryParams += '&' + encodeURIComponent('pageNo') + '=' + encodeURIComponent('1'); /* */
63 queryParams += '&' + encodeURIComponent('numOfRows') + '=' + encodeURIComponent('1000'); /* */ 67 queryParams += '&' + encodeURIComponent('numOfRows') + '=' + encodeURIComponent('1000'); /* */
64 queryParams += '&' + encodeURIComponent('dataType') + '=' + encodeURIComponent('JSON'); /* */ 68 queryParams += '&' + encodeURIComponent('dataType') + '=' + encodeURIComponent('JSON'); /* */
65 - queryParams += '&' + encodeURIComponent('base_date') + '=' + encodeURIComponent(CurDay); /* */ 69 + queryParams += '&' + encodeURIComponent('base_date') + '=' + encodeURIComponent(base); /* */
66 - queryParams += '&' + encodeURIComponent('base_time') + '=' + encodeURIComponent('0200'); /* */ 70 + queryParams += '&' + encodeURIComponent('base_time') + '=' + encodeURIComponent('2300'); /* */
67 queryParams += '&' + encodeURIComponent('nx') + '=' + encodeURIComponent(nx); /*nx*/ 71 queryParams += '&' + encodeURIComponent('nx') + '=' + encodeURIComponent(nx); /*nx*/
68 queryParams += '&' + encodeURIComponent('ny') + '=' + encodeURIComponent(ny); /*ny*/ 72 queryParams += '&' + encodeURIComponent('ny') + '=' + encodeURIComponent(ny); /*ny*/
69 73
...@@ -84,8 +88,23 @@ app.post('/api/weather',(req,res)=>{ ...@@ -84,8 +88,23 @@ app.post('/api/weather',(req,res)=>{
84 } 88 }
85 let result=[]; 89 let result=[];
86 i=0; 90 i=0;
91 + let Json;
87 while(i<a.length){ 92 while(i<a.length){
88 - let Json={today:CurDay,time:a[i].fcstTime[0]+a[i].fcstTime[1],temperature:a[i].fcstValue,rainPer:a[i+1].fcstValue}; 93 + if(a[i].fcstValue<=8){
94 + Json={today:CurDay,time:a[i].fcstTime[0]+a[i].fcstTime[1],temperature:a[i].fcstValue,rainPer:a[i+1].fcstValue,weather:0};
95 + }
96 + else if(a[i].fcstValue>8 && a[i].fcstValue<=12){
97 + Json={today:CurDay,time:a[i].fcstTime[0]+a[i].fcstTime[1],temperature:a[i].fcstValue,rainPer:a[i+1].fcstValue,weather:1};
98 + }
99 + else if(a[i].fcstValue>12 && a[i].fcstValue<=18){
100 + Json={today:CurDay,time:a[i].fcstTime[0]+a[i].fcstTime[1],temperature:a[i].fcstValue,rainPer:a[i+1].fcstValue,weather:2};
101 + }
102 + else if(a[i].fcstValue>18 && a[i].fcstValue<=23){
103 + Json={today:CurDay,time:a[i].fcstTime[0]+a[i].fcstTime[1],temperature:a[i].fcstValue,rainPer:a[i+1].fcstValue,weather:3};
104 + }
105 + else{
106 + Json={today:CurDay,time:a[i].fcstTime[0]+a[i].fcstTime[1],temperature:a[i].fcstValue,rainPer:a[i+1].fcstValue,weather:4};
107 + };
89 result.push(Json); 108 result.push(Json);
90 i+=2; 109 i+=2;
91 } 110 }
...@@ -93,4 +112,4 @@ app.post('/api/weather',(req,res)=>{ ...@@ -93,4 +112,4 @@ app.post('/api/weather',(req,res)=>{
93 });//pop:강수확률 tmp:한시간 기온 112 });//pop:강수확률 tmp:한시간 기온
94 }); 113 });
95 114
96 -app.listen(4000, () => console.log('Server On 5000'));
...\ No newline at end of file ...\ No newline at end of file
115 +app.listen(4000, () => console.log('Server On 4000'));
...\ No newline at end of file ...\ No newline at end of file
......