gpt4 book ai didi

node.js - HTTP.get 请求卡在重定向循环中

转载 作者:搜寻专家 更新时间:2023-10-31 22:39:20 25 4
gpt4 key购买 nike

我的代码中有以下几行:

postUrl =  "http://www.nytimes.com/2014/03/08/world/asia/ malaysia-airlines-says-plane-with-over-200-aboard-is-missing.html";

var htmlResult = cheerio.load(Meteor.http.call("GET", postUrl, {options: {followRedirects:false}}).content);

我收到以下错误:

Error: Exceeded maxRedirects. Probably stuck in a redirect loop

我用其他 URL 尝试了相同的代码,它可以工作,但它在 NTY url 中抛出了这个异常。我基本上是在尝试获取页面的 HEAD。

最佳答案

使用this .

在您的 http.get 调用中,您应该传递 {jar: true}

例如:

HTTP.get(url, {jar: true})

这至少对我有用:)

关于node.js - HTTP.get 请求卡在重定向循环中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22274756/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com