rss-braider/examples/request.js

28 lines
949 B
JavaScript
Raw Permalink Normal View History

2017-07-19 00:30:06 +00:00
var request = require('request');
request(
{ method: 'GET'
, uri: "http://www.jobsite.co.uk/cgi-bin/advsearch?rss_feed=1&daysback=1&jbe_id=47820652"
2017-07-19 00:32:18 +00:00
, gzip: true,
timeout: 1500
2017-07-19 00:30:06 +00:00
}
, function (error, response, body) {
// body is the decompressed response body
2017-07-19 00:34:01 +00:00
if (error !== undefined) {
console.error(error);
}
console.log(request);
2017-07-19 00:30:06 +00:00
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')
})
});