Skip to content

Instantly share code, notes, and snippets.

@ryuone
Created May 19, 2012 02:04
Show Gist options
  • Select an option

  • Save ryuone/2728620 to your computer and use it in GitHub Desktop.

Select an option

Save ryuone/2728620 to your computer and use it in GitHub Desktop.
phantom-sample.js
var page = new WebPage(),
url = 'http://www.yahoo.co.jp';
page.open(url, function (status) {
if (status !== 'success') {
console.log('Unable to access network');
} else {
var results = page.evaluate(function() {
var list = document.querySelectorAll('a'), pizza = [], i;
for (i = 0; i < list.length; i++) {
pizza.push(list[i].innerText);
}
return pizza;
});
console.log(page.content);
console.log(results.join('\n'));
}
phantom.exit();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment