Skip to content

Instantly share code, notes, and snippets.

@ariya
Created May 29, 2011 05:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ariya/997507 to your computer and use it in GitHub Desktop.
Save ariya/997507 to your computer and use it in GitHub Desktop.
Find pizza in New York using Google Local
var page = new WebPage();
page.onConsoleMessage = function (msg) {
console.log(msg);
};
page.open('http://www.google.com/m/local?site=local&q=pizza+in+new+york', function (status) {
if (status !== 'success') {
console.log('Unable to access network');
} else {
var results = page.evaluate(function() {
var list = document.querySelectorAll('div.bf'), pizza = [], i;
for (i = 0; i < list.length; i++) {
pizza.push(list[i].innerText);
}
return pizza;
});
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