Chromedp: How to catch all XHR request or redirect request like 301?

Created on 4 Aug 2020  路  3Comments  路  Source: chromedp/chromedp

I want to catch all XHR request or 301/302 request and get whole response, can we do this with cdp?

Most helpful comment

Yes, you can.

  1. Watch the network.requestWillBeSent event to get the requestId, and store the requestIds you are interested in.
  2. Watch the network.loadingFinished event to get notified when loading is complete for a request.
  3. Once loading has finished for a request, call network.getResponseBody on the requestId to get the raw response bytes.

If you want the response headers as well, you should use network.responseReceived. All of these events include a requestId, which is what you should use to associate them.

All 3 comments

Yes, you can.

  1. Watch the network.requestWillBeSent event to get the requestId, and store the requestIds you are interested in.
  2. Watch the network.loadingFinished event to get notified when loading is complete for a request.
  3. Once loading has finished for a request, call network.getResponseBody on the requestId to get the raw response bytes.

If you want the response headers as well, you should use network.responseReceived. All of these events include a requestId, which is what you should use to associate them.

cool, thanks.

Okay to close this issue then?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

howesteve picture howesteve  路  3Comments

zhaobingss picture zhaobingss  路  4Comments

aymericbeaumet picture aymericbeaumet  路  5Comments

AmrAlfoly picture AmrAlfoly  路  3Comments

opennota picture opennota  路  4Comments