Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

181
Visualizações
Puppeteer how to send PUT request to the redirected page

I am trying to send PUT request to the final URL but before final URL, there is a redirect. Also sending a fetch request inside final URL page is also fine. when I go to devtools console, write fetch from there also works but I need to do it inside the code, of course.


When I set await page.setRequestInterception(true); and page.once('request', (req) => {...}) it sends put request to the first page which I dont want it to do that.

Let's say first URL is https://example.com/first --> this redirects to final URL
final URL https://example.com/final --> this is where I want to send PUT request and retrieve status code.
I have tried setting a timer or getting current url with page.url() and trying some if else statements, but did not work.
here is my current code;

app.get('/cookie', async (req, res) => {
  puppeteer.use(StealthPlugin());

  const browser = await puppeteer.launch({
    headless: false,
    executablePath: `C:/Program Files (x86)/Google/Chrome/Application/chrome.exe`,
    defaultViewport: null,
    args: ['--start-maximized'],
    slowMo: 150,
  });
  const page = await browser.newPage();
  await page.setUserAgent(randomUserAgent.getRandom());


  page.setDefaultNavigationTimeout(0);
  page.setJavaScriptEnabled(true);  

  await page.goto(
    'finalURL',
    { waitUntil: 'load', timeout: 0 }
  );
  await delay(5000);
    
await page.setRequestInterception(true);
page.once('request', (request) => {
  request.continue({
    method: 'PUT',
  });

  page.setRequestInterception(false);
});


  let statusCode;
  await page.waitForResponse((response) => {
    statusCode = response.status();
    return true;
  });

  res.json(statusCode);
});
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda