Showing
2 changed files
with
41 additions
and
0 deletions
weather_briefing/server/location.xlsx
0 → 100644
No preview for this file type
weather_briefing/server/weather.js
0 → 100644
1 | +var request = require('request'); | ||
2 | +const xlsx=require('xlsx') | ||
3 | +const excel=xlsx.readFile('location(x,y).xlsx'); | ||
4 | +const sheet=excel.SheetNames[0]; | ||
5 | +const first=excel.Sheets[sheet]; | ||
6 | +const jsonData=xlsx.utils.sheet_to_json(first,{defval:""}); | ||
7 | +//jsonData.find() 여기서 server.js의 logid의 address123을 입력받아 이 것을 jsonData에서 찾고 싶습니다. nx와 ny에 대입 | ||
8 | +let nx,ny; | ||
9 | + | ||
10 | +var url = 'http://apis.data.go.kr/1360000/VilageFcstInfoService_2.0/getVilageFcst'; | ||
11 | +var queryParams = '?' + encodeURIComponent('serviceKey') + '=3OcUyvx97Vx2YikiZ9IHyRQ6suapku7Xn8VlefQKQWrGIFOGaejhbevwagcubdHfSiQAqJwCV5lyIutw0%2BsppA%3D%3D'; /* Service Key*/ | ||
12 | +queryParams += '&' + encodeURIComponent('pageNo') + '=' + encodeURIComponent('1'); /* */ | ||
13 | +queryParams += '&' + encodeURIComponent('numOfRows') + '=' + encodeURIComponent('1000'); /* */ | ||
14 | +queryParams += '&' + encodeURIComponent('dataType') + '=' + encodeURIComponent('JSON'); /* */ | ||
15 | +queryParams += '&' + encodeURIComponent('base_date') + '=' + encodeURIComponent('20220521'); /* */ | ||
16 | +queryParams += '&' + encodeURIComponent('base_time') + '=' + encodeURIComponent('0200'); /* */ | ||
17 | +queryParams += '&' + encodeURIComponent('nx') + '=' + encodeURIComponent('62'); /*nx*/ | ||
18 | +queryParams += '&' + encodeURIComponent('ny') + '=' + encodeURIComponent('120'); /*ny*/ | ||
19 | + | ||
20 | +request({ | ||
21 | + url: url + queryParams, | ||
22 | + method: 'GET' | ||
23 | +}, function (error, response, body) { | ||
24 | + // console.log('Status', response.statusCode); | ||
25 | + // console.log('Headers', JSON.stringify(response.headers)); | ||
26 | + // console.log('Reponse received', body); | ||
27 | + let temp=JSON.parse(body); | ||
28 | + // let tmp=temp.map((list)=> ({ | ||
29 | + // fcstTime:list.fcstTime, | ||
30 | + // category:list.category, | ||
31 | + // fcstValue:list.fcstValue | ||
32 | + // })) ; | ||
33 | + let temp2=temp.response.body.items.item.map((list)=>({ | ||
34 | + baseDate:list.baseDate, | ||
35 | + category:list.category, | ||
36 | + fcstDate:list.fcstDate, | ||
37 | + fcstTime:list.fcstTime, | ||
38 | + fcstValue:list.fcstValue | ||
39 | + })); | ||
40 | + console.log(temp2); | ||
41 | +}); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment