响应保持返回状态码403,而不是200

时间:2020-01-30 12:46:27

标签: javascript web-scraping request http-status-code-403

我正在尝试从请求中获取状态200 的响应,但一直收到 403

const request = require('request');
const cheerio = require('cheerio');

let options = {
  url: 'https://www.norwegian.com/en',
  headers: {
    "Cache-Control": "max-age=0",
    "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
    "Accept-Encoding": "gzip, deflate, br",
    "Accept-Language": "en-US,en;q=0.5",
    "Connection": "keep-alive",
    "User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:72.0) Gecko/20100101 Firefox/72.0",
  }
};

request(options, function (err, resp, html) {
  if (!err) {
    const gatherInformation = cheerio.load(html);
    console.log(resp.statusCode);
  }
})

根据Firefox开发人员工具的我的请求标头: enter image description here

0 个答案:

没有答案