nodejs encoding using request

Viewed 34992

I am trying to get the correct encoding with request.

request.get({
    "uri":'http://www.bold.dk/tv/',
    "encoding": "text/html;charset='charset=utf-8'"
  },
  function(err, resp, body){    
    console.log(body);
  }
);

No matter what I do the encoding of the danish chars are not right.

Any thoughts?

3 Answers

I have the same problem, with request v2.88.0.

Refer to woolfi makkinan's answer, I got a simple way to solve the problem.

request.get({
    "uri": 'http://www.bold.dk/tv/',
    "encoding": "text/html;charset='charset=utf-8'",
    "gzip": true // notice this config
  },
  function(err, resp, body){    
    console.log(body);
  }
);

Add gzip: true to request options, request will deal with gzip, and then blob can convert to string correctly. ​

Related