【发布时间】:2021-02-18 15:03:22
【问题描述】:
所以我正在尝试使用公共 API 提取一些 Instagram 图片:
const url = `https://www.instagram.com/${username}/?__a=1`;
fetch(url)
.then(response => response.json())
.then(data => {
prepareImages(data['graphql']['user']['edge_owner_to_timeline_media']['edges'])
})
.catch(error => console.log(error));
这在 5 次中有 4 次都可以正常工作。但是,偶尔,我会收到一条错误消息:
CORS 政策已阻止从源“https://test.com”访问“https://www.instagram.com/instagram/?__a=1”获取:否“访问控制允许” -Origin' 标头存在于请求的资源上。如果不透明的响应满足您的需求,请将请求的模式设置为“no-cors”以获取禁用 CORS 的资源。
我已尝试将模式更改为“no-cors”,但这只会导致空响应。你们是否认为他们有时只是阻止请求以防止垃圾邮件?
【问题讨论】:
标签: javascript node.js fetch instagram