Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

130
Views
Obtenga la respuesta de una solicitud de API realizada con chrome-remote-interface

Quiero obtener los datos de respuesta para la llamada a la API en particular usando chrome-remote-interface. No estoy seguro de cómo imprimir la respuesta. Puedo obtener las API a las que se llama utilizando el código de demostración disponible en su repositorio de GitHub.

Mencioné una captura de pantalla que necesito de Chrome DevTools.

 const chromeLauncher = require("chrome-launcher"); const CDP = require("chrome-remote-interface"); const axios = require("axios"); (async function () { async function launchChrome() { return await chromeLauncher.launch({ chromeFlags: ["--no-first-run", "--disable-gpu", "--no-sandbox"], }); } const chrome = await launchChrome(); const client = await CDP({ port: chrome.port, }); const { Network, Page } = client; await Page.enable(); await Network.enable(); await Page.navigate({ url: "https://clinique.com" }); await Page.loadEventFired(); Network.requestWillBeSent((params) => { if ( params.request.url === "https://www.clinique.com/rest/api/v1/ra/user?brand=2&region=0" ) { **Want to get the response for the API** } }); })();

ingrese la descripción de la imagen aquí

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede usar Network.getResponseBody para obtener el cuerpo de la respuesta que desea. Vea este ejemplo mínimo (cambié la URL de destino porque la que usó no se obtuvo de inmediato, al menos para mí):

 const chromeLauncher = require('chrome-launcher'); const CDP = require('chrome-remote-interface'); (async function () { const chrome = await chromeLauncher.launch({ chromeFlags: ['--no-first-run', '--disable-gpu', '--no-sandbox'], }); const client = await CDP({ port: chrome.port, }); const {Network, Page} = client; Network.responseReceived(async ({requestId, response}) => { if (response.url === 'https://geolocation.onetrust.com/cookieconsentpub/v1/geo/location') { const {body, base64Encoded} = await Network.getResponseBody({requestId}); console.log(body, base64Encoded); } }); await Network.enable(); await Page.navigate({url: 'https://clinique.com'}); })();
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!