nodejs encoding using request

后端 未结 3 642
面向向阳花
面向向阳花 2020-12-09 18:40

I am trying to get the correct encoding with request.

request.get({
    \"uri\":\'http://www.bold.dk/tv/\',
    \"encoding\": \"text/html;charset=\'charset=u         


        
3条回答
  •  粉色の甜心
    2020-12-09 19:38

    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. ​

提交回复
热议问题