Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- https://plus.google.com/?gpsrc=ogpy0&tab=wX
- http://www.google.com/webhp?hl=fa&tab=ww
- http://www.google.com/imghp?hl=fa&tab=wi
- http://www.youtube.com/?tab=w1
- https://mail.google.com/mail/?tab=wm
- https://drive.google.com/?tab=wo
- http://translate.google.com/?hl=fa&tab=wT
- http://www.google.com/mobile/?hl=fa&tab=wD
- var page = require('webpage').create();
- var fs=require('fs');
- var system = require('system');
- if (system.args.length < 2) {
- console.log("Usage: readFile.js FILE");
- phantom.exit(1);
- }
- var content = '',
- f = null,
- lines = null,
- eol = system.os.name == 'windows' ? "rn" : "n";
- try {
- f = fs.open(system.args[1], "rw+");
- content = f.readLine();
- page.open( content , function(status) {
- f (status !== 'success') {
- console.log('FAIL to load the address');
- }else {
- console.log('Status: ' + status);
- }
- phantom.exit();
- )};
- } catch (e) {
- console.log(e);
- }
- if (f) {
- f.close();
- }
- page.open( content , function(status)... //it gives me parse error?
- var page = require('webpage').create();
- var fs = require('fs');
- var system = require('system');
- var url = 'http://www.google.com/';
- page.open(url, function(status) {
- var links = page.evaluate(function() {
- return [].map.call(document.querySelectorAll('a.gbzt'), function(link) {
- return link.getAttribute('href');
- });
- });
- var _urls = links.join('n');
- try
- {
- fs.write('/home/ashesh/Documents/phantomjs-1.9.1-linux-x86_64/bin/Khodam/Log.txt', _urls , 'w');
- }
- catch (e)
- {
- console.log(e);
- }
- if (system.args.length < 2) {
- console.log("Usage: readFile.js FILE");
- phantom.exit(1);
- }
- var content = '',
- f = null,
- lines = null,
- eol = system.os.name == 'windows' ? "rn" : "n";
- try {
- f = fs.open(system.args[1], "r");
- content = f.read();
- } catch (e) {
- console.log(e);
- }
- if (f) {
- f.close();
- }
- if (content) {
- lines = content.split(eol);
- for (var i = 0, len = lines.length; i < len; i++) {
- page.open(lines[i], function(status) {
- //Codes .....
- )};
- }
- }
- phantom.exit();
- });
- var fs = require('fs');
- var file_h = fs.open('log.txt', 'r');
- var line = file_h.readLine();
- while(line){ console.log(line); //Do stuff here line = file_h.readLine(); }
- file_h.close();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement