Skip to content

Instantly share code, notes, and snippets.

@macbre
Last active August 29, 2015 14:01
Show Gist options
  • Save macbre/e7e2e35caf9d91af5ecf to your computer and use it in GitHub Desktop.
Save macbre/e7e2e35caf9d91af5ecf to your computer and use it in GitHub Desktop.
SlimerJS playground

Droplet installation

Debian 7

Missing libraries:

libasound.so.2: cannot open shared object file: No such file or directory
libgtk-x11-2.0.so.0: cannot open shared object file: No such file or directory
sudo aptitude install xvfb libasound2 libgtk2.0-0
{
"name": "slimer",
"version": "0.0.0",
"description": "",
"main": "script.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://gist.github.com/e7e2e35caf9d91af5ecf.git"
},
"author": "",
"license": "ISC",
"devDependencies": {
"slimerjs": "~0.9.1"
}
}
#!/bin/sh
xvfb-run \
--auto-servernum --server-num=1 \
--server-args=":1 -noreset -screen 1 1600x1200x24" \
./slimerjs --disk-cache=yes $@ script.js
var system = require('system'),
webpage = require("webpage").create(),
//url = 'http://slimerjs.org';
url = 'https://www.youtube.com/watch?v=A6j7mUxGz20';
webpage
.open(url) // loads a page
.then(function(){ // executed after loading
// store a screenshot of the page
webpage.viewportSize = { width:1600, height:1200 };
system.stdout.writeLine('Opened');
setTimeout(function() {
var then = Date.now();
system.stdout.writeLine('Rendering...');
webpage.render('page.png',{
onlyViewport:true
});
system.stdout.writeLine('Rendered in (ms): ' + (Date.now() - then));
phantom.exit()
}, 7500);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment