0

无论如何,我可以知道刮掉重定向网址的网站。例子:

request({ uri: 'http://www.toyota.com.my', encoding: 'binary' },

function (error, response, body) {
      // no response receive

}})

我猜是因为http://www.toyota.com.my/没有 html 文件。所以它无法得到响应。真正的重定向网址是http://www.toyota.com.my/index.html

我可以知道如何检测没有 html 响应的 url 吗?

4

2 回答 2

3

最终的 url 是 inresponse.request.uri.href并且所有的重定向都是 in response.request.redirects,顺便说一下,在这个例子中看起来像这样:

[ { statusCode : 302,
    redirectUri: 'http://www.toyota.com.my/index.html' } ]
于 2012-03-16T04:14:28.647 回答
0

以下对我有用request:2.81.0

console.log(response.request._redirect.redirects);    

[ { statusCode: 302, redirectUri: 'http://localhost:4000/' } ]
于 2017-03-20T14:37:32.630 回答