phantombuster / nickjs

Web scraping library made by the Phantombuster team. Modern, simple & works on all websites. (Deprecated)
https://nickjs.org
ISC License
501 stars 48 forks source link

Client Request / Server Response Headers #12

Closed mojopollo closed 6 years ago

mojopollo commented 6 years ago

Is there a way to log/view the client request headers and the server response headers?

paps commented 6 years ago

Yes, like this:

tab.driver.client.Network.requestWillBeSent((e) => {
    console.log(`-=>> requestWillBeSent: ${e.request.method} (${e.request.postData ? `sending ${e.request.postData.length} bytes` : "no post data"}) ${e.request.url}`)
})
tab.driver.client.Network.responseReceived((e) => {
    console.log(` <<=- responseReceived: ${e.response.status} (type: ${e.type}, frameId: ${e.frameId}, loaderId: ${e.loaderId}) ${e.response.url}`)
})

This is sample code, it's only logging a few of all the available fields.

mojopollo commented 6 years ago

Very cool, thank you !