-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpinterestSimple.js
45 lines (35 loc) · 1018 Bytes
/
pinterestSimple.js
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
var args = require('system').args;
var page = require('webpage').create();
var fs = require('fs');
// Find the address given as parameter
var address = '';
args.forEach(function(arg, i) {
if(i == 1) {
address = arg;
}
});
//set timeout
window.setTimeout(function () {
console.log('HTML-Error-Code: ' + "666");
phantom.exit();
}, 10000);
//only accept english
page.customHeaders = {
'Accept-Language': 'en-US',
};
//Collect the page data
page.open(address, function (resource) {
//verify if the timeline content was generated
var myReg = new RegExp('class="commentDescriptionTimeAgo"');
timeAgo = myReg.exec(page.content);
if (timeAgo == null) { return; }
console.log(page.content);
phantom.exit();
});
page.onResourceReceived = function(resource) {
if(resource.url === address && resource.status != '200') {
//console.log('Url: ' + resource.url);
console.log('HTML-Error-Code: ' + resource.status);
phantom.exit();
}
}