0

How can I get a resquest body using puppeteer?
The wanted content is showed in the picture below

Code I have so far: https://sourceb.in/ELxsmbpy0L

Thank you.

The header I wanted to get (picture)

YueYue
  • 13
  • 4

1 Answers1

0

You can get headers of request and response with this

await page.setRequestInterception(true);

page.on('request', request => {
   if (request.isInterceptResolutionHandled()) return;   

   const requestHeaders = request.headers() //getting headers of your request
   //do whatever with your request headers
});
// Opening YouTube.com
const response = await page.goto("https://www.youtube.com/watch?v=x8VYWazR5mE");

const cookies = await page.cookies()

const headers = response.headers() //getting headers of your response
const source = await response.text()
await fs.writeFile('./page.html', source);
await navigationPromise

response.headers() and request.headers() are in the document.

You can have many examples from here too

Nick Vu
  • 14,512
  • 4
  • 21
  • 31