2010-12-27 10:32:51 +03:00
|
|
|
// Find pizza in New York using Google Local
|
|
|
|
|
2011-05-26 01:16:41 +04:00
|
|
|
var page = new WebPage(),
|
|
|
|
results = [];
|
|
|
|
|
|
|
|
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 {
|
|
|
|
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'));
|
2010-12-27 10:32:51 +03:00
|
|
|
}
|
|
|
|
phantom.exit();
|
2011-05-26 01:16:41 +04:00
|
|
|
});
|