Seokjin

[UPDATE]clothesRecommendation

Showing 27 changed files with 54 additions and 8 deletions
var request = require('request');
var url = 'http://apis.data.go.kr/1360000/VilageFcstInfoService_2.0/getUltraSrtNcst';
var queryParams = '?' + encodeURIComponent('serviceKey') + '=3OcUyvx97Vx2YikiZ9IHyRQ6suapku7Xn8VlefQKQWrGIFOGaejhbevwagcubdHfSiQAqJwCV5lyIutw0%2BsppA%3D%3D'; /* Service Key*/
queryParams += '&' + encodeURIComponent('pageNo') + '=' + encodeURIComponent('1'); /* */
queryParams += '&' + encodeURIComponent('numOfRows') + '=' + encodeURIComponent('1000'); /* */
queryParams += '&' + encodeURIComponent('dataType') + '=' + encodeURIComponent('JSON'); /* */
queryParams += '&' + encodeURIComponent('base_date') + '=' + encodeURIComponent('20220605'); /* */
queryParams += '&' + encodeURIComponent('base_time') + '=' + encodeURIComponent('0600'); /* */
queryParams += '&' + encodeURIComponent('nx') + '=' + encodeURIComponent('55'); /* */
queryParams += '&' + encodeURIComponent('ny') + '=' + encodeURIComponent('127'); /* */
request({
url: url + queryParams,
method: 'GET'
}, function (error, response, body) {
//console.log('Status', response.statusCode);
//console.log('Headers', JSON.stringify(response.headers));
console.log('Reponse received', body);
});
\ No newline at end of file
......@@ -13,4 +13,11 @@
자켓:https://www.musinsa.com/app/goods/2594389
가디건:https://www.musinsa.com/app/goods/1139192/0
청자켓:https://www.musinsa.com/app/goods/1790382
트렌치코트:https://www.musinsa.com/app/goods/2594302
\ No newline at end of file
트렌치코트:https://www.musinsa.com/app/goods/2594302
핫팬츠:https://www.musinsa.com/app/goods/948562
조거팬츠:https://www.musinsa.com/app/goods/948562
롱스커트:https://www.musinsa.com/app/goods/2287458
패딩:https://www.musinsa.com/app/goods/1616798
가죽자켓:https://www.musinsa.com/app/goods/1758197
기모옷:https://www.musinsa.com/app/goods/1718829
울코트:https://www.musinsa.com/app/goods/722573
\ No newline at end of file
......
......@@ -7,8 +7,8 @@ let app = express();
app.use(cors());
let logid=null;
//const uri = 'mongodb+srv://sjieu17:tjrwls147714@cluster0.lc6pe.mongodb.net/weather_briefing?retryWrites=true&w=majority';
const uri = 'mongodb+srv://tahmkench:dkrldnsl7@cluster0.vzipl.mongodb.net/?retryWrites=true&w=majority';
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';
// const uri = 'mongodb+srv://tahmkench:dkrldnsl7@cluster0.vzipl.mongodb.net/?retryWrites=true&w=majority';
let db = mongoose.connect(uri, (err) => {
if (err) {
......
......@@ -17,6 +17,8 @@ var url = 'http://apis.data.go.kr/1360000/VilageFcstInfoService_2.0/getVilageFcs
var queryParams = '?' + encodeURIComponent('serviceKey') + '=3OcUyvx97Vx2YikiZ9IHyRQ6suapku7Xn8VlefQKQWrGIFOGaejhbevwagcubdHfSiQAqJwCV5lyIutw0%2BsppA%3D%3D'; /* Service Key*/
//오늘의 날짜 구하기
let base;
let today=new Date();
let CurDay=today.getFullYear().toString();
if(today.getMonth()<9){
......@@ -26,12 +28,14 @@ else{
CurDay+=(today.getMonth()+1).toString();
}
if(today.getDate()<10){
base=CurDay+"0"+(today.getDate()-1).toString();
CurDay+="0"+today.getDate().toString();
}
else{
base=CurDay+(today.getDate()-1).toString();
CurDay+=today.getDate().toString();
}
console.log(base);
//nx,ny구하기
const xlsx=require('xlsx')
const excel=xlsx.readFile('location.xlsx');
......@@ -62,8 +66,8 @@ app.post('/api/weather',(req,res)=>{
queryParams += '&' + encodeURIComponent('pageNo') + '=' + encodeURIComponent('1'); /* */
queryParams += '&' + encodeURIComponent('numOfRows') + '=' + encodeURIComponent('1000'); /* */
queryParams += '&' + encodeURIComponent('dataType') + '=' + encodeURIComponent('JSON'); /* */
queryParams += '&' + encodeURIComponent('base_date') + '=' + encodeURIComponent(CurDay); /* */
queryParams += '&' + encodeURIComponent('base_time') + '=' + encodeURIComponent('0200'); /* */
queryParams += '&' + encodeURIComponent('base_date') + '=' + encodeURIComponent(base); /* */
queryParams += '&' + encodeURIComponent('base_time') + '=' + encodeURIComponent('2300'); /* */
queryParams += '&' + encodeURIComponent('nx') + '=' + encodeURIComponent(nx); /*nx*/
queryParams += '&' + encodeURIComponent('ny') + '=' + encodeURIComponent(ny); /*ny*/
......@@ -84,8 +88,23 @@ app.post('/api/weather',(req,res)=>{
}
let result=[];
i=0;
let Json;
while(i<a.length){
let Json={today:CurDay,time:a[i].fcstTime[0]+a[i].fcstTime[1],temperature:a[i].fcstValue,rainPer:a[i+1].fcstValue};
if(a[i].fcstValue<=8){
Json={today:CurDay,time:a[i].fcstTime[0]+a[i].fcstTime[1],temperature:a[i].fcstValue,rainPer:a[i+1].fcstValue,weather:0};
}
else if(a[i].fcstValue>8 && a[i].fcstValue<=12){
Json={today:CurDay,time:a[i].fcstTime[0]+a[i].fcstTime[1],temperature:a[i].fcstValue,rainPer:a[i+1].fcstValue,weather:1};
}
else if(a[i].fcstValue>12 && a[i].fcstValue<=18){
Json={today:CurDay,time:a[i].fcstTime[0]+a[i].fcstTime[1],temperature:a[i].fcstValue,rainPer:a[i+1].fcstValue,weather:2};
}
else if(a[i].fcstValue>18 && a[i].fcstValue<=23){
Json={today:CurDay,time:a[i].fcstTime[0]+a[i].fcstTime[1],temperature:a[i].fcstValue,rainPer:a[i+1].fcstValue,weather:3};
}
else{
Json={today:CurDay,time:a[i].fcstTime[0]+a[i].fcstTime[1],temperature:a[i].fcstValue,rainPer:a[i+1].fcstValue,weather:4};
};
result.push(Json);
i+=2;
}
......@@ -93,4 +112,4 @@ app.post('/api/weather',(req,res)=>{
});//pop:강수확률 tmp:한시간 기온
});
app.listen(4000, () => console.log('Server On 5000'));
\ No newline at end of file
app.listen(4000, () => console.log('Server On 4000'));
\ No newline at end of file
......