【问题标题】:403 from a http request to a Cloudflare hosted website从 http 请求到 Cloudflare 托管网站的 403
【发布时间】:2021-05-31 12:34:36
【问题描述】:

我使用 axios 解析一个网站,我得到这个错误:

错误:请求失败,状态码 403

我尝试设置自定义用户代理,但没有成功

module.exports.get_output = function (url) {
axios({
    method: 'get',
    url: url,
    headers: {User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.192 Safari/537.36'}
})
    .then(function (res) {
        console.log(res)
    })
}

我知道这是一个 Cloudflare 网站,但我找不到绕过它的方法 - 大多数建议建议伪装成浏览器,但我也尝试过。

【问题讨论】:

    标签: javascript node.js axios cloudflare http-status-code-403


    【解决方案1】:

    默认情况下,Cloudflare 对 API 不友好,我通过在 Cloudflare Dashboard 中禁用“浏览器完整性检查”解决了这个问题。

    相关讨论:https://community.cloudflare.com/t/api-403-after-enabling-cloudflare/108078/6

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-10-31
      • 2017-04-08
      • 1970-01-01
      • 2020-06-13
      • 1970-01-01
      • 2020-07-05
      • 2012-11-13
      • 2010-12-05
      相关资源
      最近更新 更多