phantomScript.js 611 B

12345678910111213141516171819202122232425262728
  1. var page = require('webpage').create(),
  2. system = require('system'),
  3. t,address;
  4. if (system.args.length === 1){
  5. console.log ('Usage: phantomjs --proxy=localhost:8080 --proxy-type=http phantomScript.js <some URL>');
  6. phantom.exit();
  7. }
  8. t = Date.now();
  9. address = system.args[1];
  10. console.log('Loading page..'+ system.args[1]);
  11. page.open(address, function(status){
  12. if (status !== 'success'){
  13. console.log('FAIL to load the address');
  14. console.log(status);
  15. }
  16. else{
  17. t = Date.now() - t;
  18. console.log('Loading page..'+ system.args[1]);
  19. console.log('Loading time: '+ t + 'msec');
  20. }
  21. phantom.exit();
  22. });