Seokjin

[update]weather

No preview for this file type
var request = require('request');
const xlsx=require('xlsx')
const excel=xlsx.readFile('location(x,y).xlsx');
const sheet=excel.SheetNames[0];
const first=excel.Sheets[sheet];
const jsonData=xlsx.utils.sheet_to_json(first,{defval:""});
//jsonData.find() 여기서 server.js의 logid의 address123을 입력받아 이 것을 jsonData에서 찾고 싶습니다. nx와 ny에 대입
let nx,ny;
var url = 'http://apis.data.go.kr/1360000/VilageFcstInfoService_2.0/getVilageFcst';
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('20220521'); /* */
queryParams += '&' + encodeURIComponent('base_time') + '=' + encodeURIComponent('0200'); /* */
queryParams += '&' + encodeURIComponent('nx') + '=' + encodeURIComponent('62'); /*nx*/
queryParams += '&' + encodeURIComponent('ny') + '=' + encodeURIComponent('120'); /*ny*/
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);
let temp=JSON.parse(body);
// let tmp=temp.map((list)=> ({
// fcstTime:list.fcstTime,
// category:list.category,
// fcstValue:list.fcstValue
// })) ;
let temp2=temp.response.body.items.item.map((list)=>({
baseDate:list.baseDate,
category:list.category,
fcstDate:list.fcstDate,
fcstTime:list.fcstTime,
fcstValue:list.fcstValue
}));
console.log(temp2);
});
\ No newline at end of file