-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpinterest.js
45 lines (37 loc) · 1.03 KB
/
pinterest.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
var args = require('system').args;
var page = require('webpage').create();
var fs = require('fs');
var number = 0;
// Find the address given as parameter
var address = '';
args.forEach(function(arg, i) {
if(i == 1) {
address = arg;
}
});
// Count how many boards are in the page
var countItens = function(){
var reg = new RegExp('_tw _2k', 'g');
var count = page.content.match(reg);
if (count) { return count.length;}
return 0
}
//Collect the page data
page.open(address, function (status) {
if (status === "success") {
window.setInterval(function() {
// console.log("Now items : "+countItens());
if (number < countItens()){
number = countItens()
page.evaluate(function() {
window.document.body.scrollTop = document.body.scrollHeight;
});
}
else{
console.log(page.content);
page.render("page200.png");
phantom.exit();
}
}, 1500);
}
});