Hi, I'm trying to learn these technologies.  When I run this phantomjs
script:

var page = new WebPage(),
    url = 'http://lite.yelp.com/search?
find_desc=pizza&find_loc=94040&find_submit=Search';

page.open(url, function (status) {
    if (status == 'success') {

        var results = page.evaluate(function() {
            var list = document.querySelectorAll('span.address'),
pizza = [], i;
            for (i = 0; i < list.length; i++) {
                pizza.push(list[i].innerText);
            }
            return pizza;
        });
        console.log(results.join('\n'));
    }
    phantom.exit();
});

I get the right results but when I try to port this to Node with
phantomjs-node like this:

phantom = require('phantom');

phantom.create(function (ph) {
    ph.createPage(function (page) {
        page.open("http://lite.yelp.com/search?
find_desc=pizza&find_loc=94040&find_submit=Search", function (status)
{

            page.evaluate((function () {
                list = document.querySelectorAll('span.address'),
pizza = [], i
                for (i = 0; i < list.length; i++) {
                    pizza.push(list[i].innerText);
                }
                return pizza;

            }), function (result) {
                console.log(result)
                ph.exit();
            });
        });
    });
});

It returns 'null' no matter what I try.  I figure I'm not wrapping
something in an anonymous function.  Any ideas?


-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to