Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Sep 5th, 2013  |  syntax: None  |  size: 2.52 KB  |  views: 245  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. https://plus.google.com/?gpsrc=ogpy0&tab=wX
  2. http://www.google.com/webhp?hl=fa&tab=ww
  3. http://www.google.com/imghp?hl=fa&tab=wi
  4. http://www.youtube.com/?tab=w1
  5. https://mail.google.com/mail/?tab=wm
  6. https://drive.google.com/?tab=wo
  7. http://translate.google.com/?hl=fa&tab=wT
  8. http://www.google.com/mobile/?hl=fa&tab=wD
  9.        
  10. var page = require('webpage').create();
  11. var fs=require('fs');
  12. var system = require('system');
  13.     if (system.args.length < 2) {
  14.         console.log("Usage: readFile.js FILE");
  15.         phantom.exit(1);
  16.     }
  17.     var content = '',
  18.         f = null,
  19.         lines = null,
  20.         eol = system.os.name == 'windows' ? "rn" : "n";
  21.     try {
  22.         f = fs.open(system.args[1], "rw+");
  23.         content = f.readLine();
  24.         page.open( content , function(status) {
  25.             f (status !== 'success') {
  26.         console.log('FAIL to load the address');
  27.                 }else {
  28.          console.log('Status: ' + status);
  29.                  }
  30.          phantom.exit();
  31.                 )};
  32.     } catch (e) {
  33.         console.log(e);
  34.     }
  35.     if (f) {
  36.         f.close();
  37.     }
  38.        
  39. page.open( content , function(status)...  //it gives me parse error?
  40.        
  41. var page = require('webpage').create();
  42. var fs = require('fs');
  43. var system = require('system');
  44. var url = 'http://www.google.com/';
  45. page.open(url, function(status) {
  46.     var links = page.evaluate(function() {
  47.         return [].map.call(document.querySelectorAll('a.gbzt'), function(link) {
  48.             return link.getAttribute('href');
  49.         });
  50.     });
  51.     var _urls = links.join('n');
  52.     try
  53.     {
  54.         fs.write('/home/ashesh/Documents/phantomjs-1.9.1-linux-x86_64/bin/Khodam/Log.txt', _urls , 'w');
  55.     }
  56.     catch (e)
  57.     {
  58.         console.log(e);
  59.     }
  60.     if (system.args.length < 2) {
  61.         console.log("Usage: readFile.js FILE");
  62.         phantom.exit(1);
  63.     }
  64.     var content = '',
  65.         f = null,
  66.         lines = null,
  67.         eol = system.os.name == 'windows' ? "rn" : "n";
  68.     try {
  69.         f = fs.open(system.args[1], "r");
  70.         content = f.read();
  71.     } catch (e) {
  72.         console.log(e);
  73.     }
  74.     if (f) {
  75.         f.close();
  76.     }
  77.     if (content) {
  78.         lines = content.split(eol);
  79.         for (var i = 0, len = lines.length; i < len; i++) {
  80.             page.open(lines[i], function(status) {
  81.                 //Codes .....
  82.                 )};
  83.         }
  84.     }  
  85.     phantom.exit();
  86.     });
  87.        
  88. var fs = require('fs');
  89. var file_h = fs.open('log.txt', 'r');
  90. var line = file_h.readLine();
  91.  
  92. while(line){    console.log(line); //Do stuff here     line = file_h.readLine(); }
  93. file_h.close();
clone this paste RAW Paste Data