Last active

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

taking phantomjs for a test drive

View gist:1491205
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
// http://www.phantomjs.org/
 
var page = require('webpage').create();
page.onConsoleMessage = function(msg) {
console.log(msg);
};
 
console.log('[phantomjs] Loading page...');
 
page.open('http://blog.founddrama.net/', function(status){
if (status !== 'success') {
console.log('could not retrieve!');
} else {
page.evaluate(function(){
console.log('[phantomjs] Querying for post titles...');
var list = Array.prototype.slice.call(document.querySelectorAll('h2 > a[rel="bookmark"]'), 0);
console.log('[phantomjs] ' + list.length + ' post titles:');
list.forEach(function(el){
console.log(' ' + el.innerHTML.replace(/<.*?>/g, ''));
});
});
}
phantom.exit();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.