Created
June 6, 2017 08:48
-
-
Save shirou/432835c9737b2029f70e092775c2f978 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const CDP = require('chrome-remote-interface'); | |
CDP((client) => { | |
// extract domains | |
const {Network, Page, Input} = client; | |
// setup handlers | |
Network.requestWillBeSent((params) => { | |
console.log(params.request.url); | |
}); | |
Page.loadEventFired(() => { | |
client.close(); | |
}); | |
// enable events then start! | |
Promise.all([ | |
Network.enable(), | |
Page.enable() | |
]).then(() => { | |
return Page.navigate({url: 'https://github.com'}); | |
}).catch((err) => { | |
console.error(err); | |
client.close(); | |
}); | |
}).on('error', (err) => { | |
// cannot connect to the remote endpoint | |
console.error(err); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment