2011-08-24 10:34:14 +04:00
|
|
|
// Find pizza in Mountain View using Yelp
|
2010-12-27 10:32:51 +03:00
|
|
|
|
2011-08-24 10:34:14 +04:00
|
|
|
var page = new WebPage(),
|
|
|
|
url = 'http://lite.yelp.com/search?find_desc=pizza&find_loc=94040&find_submit=Search';
|
2011-05-26 01:16:41 +04:00
|
|
|
|
2011-08-24 10:34:14 +04:00
|
|
|
page.open(url, function (status) {
|
2011-05-26 01:16:41 +04:00
|
|
|
if (status !== 'success') {
|
|
|
|
console.log('Unable to access network');
|
|
|
|
} else {
|
2011-05-26 01:23:10 +04:00
|
|
|
var results = page.evaluate(function() {
|
2011-08-24 10:34:14 +04:00
|
|
|
var list = document.querySelectorAll('span.address'), pizza = [], i;
|
2011-05-26 01:16:41 +04:00
|
|
|
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
|
|
|
});
|