Merge branch 'feature/BoxOffice' into 'feature/BoxOfficeAPI'
Feature/box office Add feature testing boxoffice api See merge request !1
Showing
2 changed files
with
61 additions
and
0 deletions
BoxOffice/app.js
0 → 100644
1 | +let express = require('express'); | ||
2 | +let app = express(); | ||
3 | +let request = require('request'); | ||
4 | +let bodyParser = require('body-parser'); | ||
5 | +const { response } = require('express'); | ||
6 | + | ||
7 | +app.use(bodyParser.urlencoded({ extended: false })); | ||
8 | +app.use(bodyParser.json()); | ||
9 | + | ||
10 | + | ||
11 | +let today = new Date(); | ||
12 | +let year = today.getFullYear(); | ||
13 | +let month = ("0" + (1 + today.getMonth())).slice(-2); | ||
14 | +let day = ("0" + today.getDate()).slice(-2); | ||
15 | +let date = year + month + day-1; | ||
16 | +//YYYYMMDD | ||
17 | + | ||
18 | +//console.log(date); | ||
19 | + | ||
20 | +let key = "b70513efc156d7b826bb8dc98ff2f1cf"; | ||
21 | +let url = "http://kobis.or.kr/kobisopenapi/webservice/rest/boxoffice/searchDailyBoxOfficeList.json?key=" + key + "&targetDt="; | ||
22 | +let rank = 5 | ||
23 | +// apiurl = url + date + "&itemPerPage=" +rank-> "출력할 박스오피스 순위(5: 5위 까지, 10 : 10위 까지.../기본, 최대 10)" | ||
24 | +//console.log(url); | ||
25 | + | ||
26 | +let options = { | ||
27 | + 'method' : 'GET', | ||
28 | + 'url' : url + date + "&itemPerPage=" + rank | ||
29 | +}; | ||
30 | + | ||
31 | +request(options, function (error, response, body){ | ||
32 | + if (error){ | ||
33 | + throw new Error(error); | ||
34 | + } | ||
35 | + let info = JSON.parse(body); | ||
36 | + console.log(info); | ||
37 | +}); | ||
38 | + | ||
39 | +// 박스오피스 순위 출력 | ||
40 | + | ||
41 | + | ||
42 | + | ||
43 | + | ||
44 | + | ||
45 | + | ||
46 | +let server = app.listen(80); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
BoxOffice/package.json
0 → 100644
1 | +{ | ||
2 | + "name": "Testing BoxOffice API", | ||
3 | + "version": "1.0.0", | ||
4 | + "description": "", | ||
5 | + "main": "index.js", | ||
6 | + "scripts": { | ||
7 | + "test": "echo \"Error: no test specified\" && exit 1" | ||
8 | + }, | ||
9 | + "author": "", | ||
10 | + "license": "ISC", | ||
11 | + "dependencies": { | ||
12 | + "body-parser": "^1.17.1", | ||
13 | + "express": "^4.15.2" | ||
14 | + } | ||
15 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment