You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Puppeteer登录sisal.it网站时出现403禁止错误的问题求助

使用Puppeteer登录sisal.it网站时出现403禁止错误的问题求助

我最近在使用Puppeteer登录sisal.it的私人区域时碰到了头疼的问题:通过Puppeteer发起登录请求时,会返回**403(Forbidden)**错误,但用同一个账号手动打开浏览器完成登录却完全正常。更奇怪的是,就算我用Puppeteer启动有头浏览器,手动一步步完成登录操作,请求还是会失败。

以下是我目前的代码:

const puppeteer = require('puppeteer');

(async () => {

const browser = await puppeteer.launch({
    headless: false,
    ignoreDefaultArgs: ['--enable-automation']
});

const page = await browser.newPage();

// Navigate to the page that will perform the tests.
await page.setViewport({ width: 1366, height: 1024});
await page.setExtraHTTPHeaders({
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:98.0) Gecko/20100101 Firefox/98.0",
    "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
    "Accept-Language": "en-US,en;q=0.5",
    "Accept-Encoding": "gzip, deflate",
    "Connection": "keep-alive",
    "Upgrade-Insecure-Requests": "1",
    "Sec-Fetch-Dest": "document",
    "Sec-Fetch-Mode": "navigate",
    "Sec-Fetch-Site": "none",
    "Sec-Fetch-User": "?1",
    "Cache-Control": "max-age=0",
    "Access-Control-Allow-Origin": "https://areaprivata.sisal.it"
});

await page.goto('https://chrome.google.com/webstore');
await page.waitForNavigation();
await page.goto('https://areaprivata.sisal.it/loginJwt');
await page.waitForSelector('input[name="usernameEtc"]');
await page.type('input[name="usernameEtc"]', 'TEST');
await page.keyboard.press('Tab');
await page.keyboard.down('Shift');
await page.keyboard.type('t');
await page.keyboard.up('Shift');
await page.keyboard.type('est');
await page.click('#buttonAuth');
})();

我已经尝试在登录前设置了不少请求头和启动参数(如代码所示),但问题依然存在。另外如果我传入某些特定参数的话,甚至连登录请求都发不出去,还会出现CORS相关的错误。有没有大佬能帮我分析下问题出在哪,或者给点解决思路?

备注:内容来源于stack exchange,提问作者s4lvious

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.20 13:05:30