Advertisement
metalx1000

Use Chrome Headless to list all URL request of page

Oct 14th, 2018
1,075
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #list all url requests in chrome browser using Chrome Headless
  2.  
  3. #start chrome headless
  4. google-chrome --headless --remote-debugging-port=9222
  5.  
  6. #run the script below with nodejs
  7. nodejs script.js
  8.  
  9. #now open chrome and navigate to page
  10. #click on about:blank then type address
  11. google-chrome "http://localhost:9222
  12.  
  13. //STart script//
  14. var Chrome = require('chrome-remote-interface');
  15. Chrome(function (chrome) {
  16.    with (chrome) {
  17.        Network.requestWillBeSent(function (params) {
  18.            console.log(params.request.url);
  19.        });
  20.        //Page.loadEventFired(close);
  21.        Network.enable();
  22.        Page.enable();
  23.      /*  once('ready', function () {
  24.            Page.navigate({'url': 'https://filmsbykris.com'});
  25.        });
  26.        */
  27.    }
  28. }).on('error', function (err) {
  29.    console.error('Cannot connect to Chrome:', err);
  30. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement