loadurlwithoutcss.js 693 B

12345678910111213141516171819202122232425
  1. var page = require('webpage').create(),
  2. system = require('system');
  3. if (system.args.length < 2) {
  4. console.log('Usage: loadurlwithoutcss.js URL');
  5. phantom.exit();
  6. }
  7. var address = system.args[1];
  8. page.onResourceRequested = function(requestData, request) {
  9. if ((/http:\/\/.+?\.css/gi).test(requestData['url']) || requestData['Content-Type'] == 'text/css') {
  10. console.log('The url of the request is matching. Aborting: ' + requestData['url']);
  11. request.abort();
  12. }
  13. };
  14. page.open(address, function(status) {
  15. if (status === 'success') {
  16. phantom.exit();
  17. } else {
  18. console.log('Unable to load the address!');
  19. phantom.exit();
  20. }
  21. });