i'm using mikeal/request. I have a problems with some webpage when i use:
var url='http://www.youtube.com/watch?v=YbP1K-bQB6g&list=SP018BE450221B431B';
var request = require('request');
request(url, function (error, response, body) {
console.log(body);
})
this print the body well-formatted in html. Sometimes with different urls it prints something like:
ÿÿ´Wmo7þ|ú¦{@ã »ZÉ9ŸãÄ2 تOl+¶Ü4W½Kèì’[’+K.úé~ ecc...
but when i navigate it trought the browser i can see the page clearly. Any suggestion? I already tried to decode it with StringDecoder but nothing... i'm using this url to get the error:
http://www.agi.it/estero/notizie/201210250805-est-rt10017-performance_stellari_e_10_ore_autonomia_e_gia_ipad_mini_mania
The response is gzipped, it seems. If you can't get the server to honor your request headers, you'll need to decode the response.
EDIT: You can explicitly set the request headers like this:
request({ url: <your url>, headers: { 'accept-encoding': 'identity' }}, function (error, reponse, body) {
// You really should receive an un-encoded body, now
});