-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
40 lines (33 loc) · 1.04 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var express = require('express');
var fs = require('fs');
var request = require('request');
var cheerio = require('cheerio');
var app = express();
const fetch = require('node-fetch');
app.get('/test', function (req, res) {
res.send('Hello World!')
const data = {cmpy_id:187,security_id:125,startDate:"02-20-1991",endDate:"08-11-2017"}
const options = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Host':'edge.pse.com.ph',
'Origin':'http://edge.pse.com.ph',
'Referer':'http://edge.pse.com.ph/companyPage/stockData.do?cmpy_id=187'
},
body: JSON.stringify(data)
};
function handleJson(data) {
console.log(data.chartData);
}
fetch('http://edge.pse.com.ph/common/DisclosureCht.ax', options)
.then(response => response.json())
.then(handleJson)
.catch(console.log);
})
app.listen(3001, function () {
console.log('Example app listening on port 3001!')
})
console.log('Magic happens on port 8081');
exports = module.exports = app;