rss-braider/examples/request.js
2017-07-19 01:34:01 +01:00

28 lines
949 B
JavaScript

var request = require('request');
request(
{ method: 'GET'
, uri: "http://www.jobsite.co.uk/cgi-bin/advsearch?rss_feed=1&daysback=1&jbe_id=47820652"
, gzip: true,
timeout: 1500
}
, function (error, response, body) {
// body is the decompressed response body
if (error !== undefined) {
console.error(error);
}
console.log(request);
console.log('server encoded the data as: ' + (response.headers['content-encoding'] || 'identity'))
console.log('the decoded data is: ' + body)
}
)
.on('data', function(data) {
// decompressed data as it is received
console.log('decoded chunk: ' + data)
})
.on('response', function(response) {
// unmodified http.IncomingMessage object
response.on('data', function(data) {
// compressed data as it is received
console.log('received ' + data.length + ' bytes of compressed data')
})
});