Node.js 在nodejs中将curl命令转换为request-promise命令时出现问题

Node.js 在nodejs中将curl命令转换为request-promise命令时出现问题,node.js,curl,Node.js,Curl,所以我知道这个curl命令确实有效。当我运行它时,我会得到该登录后应显示的html文档: curl 'https://login.url' -H 'Pragma: no-cache' -H 'Origin: https://blah' -H 'Accept-Encoding: gzip, deflate, br' -H 'Accept-Language: en-US,en;q=0.8' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent:

所以我知道这个curl命令确实有效。当我运行它时,我会得到该登录后应显示的html文档:

curl 'https://login.url' 
-H 'Pragma: no-cache' 
-H 'Origin: https://blah' 
-H 'Accept-Encoding: gzip, deflate, br' 
-H 'Accept-Language: en-US,en;q=0.8' 
-H 'Upgrade-Insecure-Requests: 1' 
-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.76 Safari/537.36' 
-H 'Content-Type: application/x-www-form-urlencoded' 
-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' 
-H 'Cache-Control: no-cache' 
-H 'Referer: https://blash.jsp' 
-H 'Connection: keep-alive' 
--data 'Username=mary&Password=<PASSWORD>&Go=Login&Action=Srh-1-1' --compressed ;

我做错了什么?

您需要通过将
gzip
选项设置为true来告诉
request
您接受压缩

请注意,根据获取数据的方式/位置,可能会得到压缩或未压缩的响应。查看详细信息(在页面上搜索“compr”)

var url = 'https://login.url';

var headers = {
  'Pragma': 'no-cache',
  'Origin': 'https://blah',
  'Accept-Encoding': 'gzip, deflate, br',
  'Accept-Language': 'en-US,en;q=0.8',
  'Upgrade-Insecure-Requests': '1',
  'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.76 Safari/537.36',
  'Content-Type': 'application/x-www-form-urlencoded',
  'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
  'Cache-Control': 'no-cache',
  'Referer': 'https://blash.jsp',
  'Connection': 'keep-alive',
}

var data = {
  'Username':'mary',
  'Password':'<Password>',
  'Go':'Login',
  'Action':'Srh-1-1'
}

var html = yield request.post({url:url,form:data,headers:headers});
�X}o�6����4\��b�N��%