save.js 496 B

1234567891011121314151617181920212223
  1. var system = require('system');
  2. var page = require('webpage').create();
  3. var url = system.args[1];
  4. var destination = system.args[2];
  5. page.settings.resourceTimeout = 10000;
  6. setTimeout(function(){
  7. setInterval(function () {
  8. var fs = require('fs');
  9. var page = require('webpage').create();
  10. page.open(url, function () {
  11. console.log(page.content);
  12. try {
  13. fs.write(destination, page.content, 'w');
  14. } catch(e) {
  15. console.log(e);
  16. }
  17. phantom.exit();
  18. });
  19. }, 20000);
  20. }, 1);