Created
September 27, 2015 07:02
-
-
Save Wcc723/f63e7c3af5c621db5b40 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'); | |
// var buffer = require('buffer'); | |
var url = "/ws/Data/AQX/?$orderby=SiteName&$skip=0&$top=1000&format=json" | |
var Options = { | |
R1: { | |
hostname: 'opendata.epa.gov.tw', | |
path: url, | |
method: 'GET', | |
headers: { | |
'Content-Type': 'application/json', | |
'Upgrade-Insecure-Requests': 1, | |
'User-Agent': "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36", | |
} | |
} | |
}; | |
var req = http.request(Options.R1 , function(res){ | |
// console.log(res); | |
var body = ''; | |
res.on('data' , function(chunk){ | |
// console.dir(chunk); | |
var str = new Buffer(chunk); | |
body+= str; | |
}) | |
res.on('end' , function(){ | |
console.log('end'); | |
console.log(body); | |
}) | |
}) | |
req.end(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment