Instagram JSON 响应重定向到登录 [Discord JS 和 Heroku]



我正在制作一个不和谐的机器人,更准确地说是学习如何。 如果我在自己的计算机上本地运行机器人,它会返回正确的 json 响应,其中包含所有配置文件详细信息等,但如果我将其托管在 Heroku 上,我会在 Heroku 日志中收到以下错误

2020-06-09T23:47:45.215756+00:00 app[worker.1]: An error occurred: FetchError: invalid json response body at https://www.instagram.com/accounts/login/?next=/gucci/%3F__a%3D1 reason: Unexpected token < in JSON at position 0

如果我转到错误中的链接:https://www.instagram.com/accounts/login/?next=/gucci/%3F__a%3D1

我收到了登录表单。我怎样才能绕过这个?

同样,如果我在自己的计算机上运行机器人,它工作得很好。只有当我在 Heroku 上托管它时,它才会发生。这是获取代码。

const igUsername = args[0].toLowerCase();
const url = `http://www.instagram.com/${igUsername}/?__a=1`;
const res = await fetch(url).then(resUrl => resUrl.json()).catch(err => {
console.log(`An error occurred: ${err}`);
return message.reply('Something went wrong! If this isn't fixed in the next hour, please appeal a complaint in my discord server!');
});

我没有足够的代表来评论,但问题是您的服务器的 ip 已被标记,他们只允许消费者设备 ip 查询它,因为限制

最新更新