-
Notifications
You must be signed in to change notification settings - Fork 0
/
capture.js
44 lines (27 loc) · 849 Bytes
/
capture.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 page = require("webpage").create();
// Dimensions don't really matter but need to be non-zero
var width = 1,
height = 1,
url = "https://bl.ocks.org/veltman/raw/63c1ace02b74988fcddf/";
page.viewportSize = { width: width, height: height};
page.open(url, function (status) {
var waited = 0,
timeout = 60000,
interval = 100;
// Wait until the base64 is ready
setInterval(function() {
waited += interval;
var base64 = page.evaluate(function(){
return phantomReady;
});
if (base64) {
// Write base64 to stdout for decoding
console.log(base64);
phantom.exit();
} else if (waited > timeout) {
// Give up, something's wrong
require("system").stderr.write("Maximum timeout of " + timeout + "ms exceeded.\n");
phantom.exit();
}
},interval);
});