-
Notifications
You must be signed in to change notification settings - Fork 0
/
pagetitle25
49 lines (37 loc) · 835 Bytes
/
pagetitle25
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
var system = require('system');
var args = system.args;
var url;
var isDone=[];
if (args.length <= 1) {
console.log('No website specified.');
phantom.exit();
}
for (var k=0; k<args.length; k++) {
isDone[k] = false;
}
function exitIfDone() {
for (var j=1; j<=args.length-1; j++) {
if (isDone[j]==false) {
return;
}
}
phantom.exit();
}
function getOnePageTitle(url, index) {
var page = require('webpage').create();
page.onConsoleMessage = function(msg) {
console.log(msg);
};
page.open(url, function(status) {
page.evaluate(function() {
//title[i]=document.title;
console.log(document.location + 'Page title is ' + title[i]);
});
});
isDone[index]=true;
}
for (var i=1; i<=args.length-1; i++) {
url = args[i];
getOnePageTitle(url, i);
exitIfDone();
}