0

I'm trying to run Phantomjs (most specifically Casperjs) on a Amazon EC2, using Ubuntu latest image (12.4). To be sure, I tried with two different builds. One compiled on my dev machine (Phantomjs 1.6.0) and another built in the EC2 itself (Phantomjs 1.6.1).

Both with same results: The connection doesn't happen.

Using the pizza example:

I can

wget 'http://lite.yelp.com/search?find_desc=pizza&find_loc=94040&find_submit=Search'

and I get the requested page, but when I run

phantomjs examples/pizza.js

I get

Unable to access network.

There are no rules active on iptables.

Any hints on what might be causing that? Or what should I do to get more details about the issue?

Thanks.

1 Answer 1

0

In that example, the Phantom script will throw "unable to access network" if the request doesn't return 'success'. In fact, a request to the URL in your example returns a 301 'moved permanently' and redirects back to yelp.com/search. I believe the example is outdated and Yelp have since updated their website UI.

Url format is now: http://www.yelp.com/search#find_desc=pizza&find_loc=San+Francisco&show_filters=1

And the address now sits in an <address> element.

Update the url and the selector to something like:

document.querySelectorAll('address')

Also,the example script you've linked to is for Phantom 1.2. The following is deprecated:

var page = new WebPage();

And replaced by the following in newer versions:

var page = require('webpage').create();

Same example for Phantom 1.6. Remember to update the url and selector: http://code.google.com/p/phantomjs/source/browse/examples/pizza.js?name=1.6

2
  • Thanks rbaker86, but that is not the issue.
    – alfetopito
    Commented Jul 17, 2012 at 12:13
  • I added that just as an example which would throw some kind of error in case it failed. The root cause is that the Ubuntu image I was using somehow blocked phantomjs connections (could not figure out why/how) I just instantiated an Amazon Linux AMI and it worked without any issue out of the box.
    – alfetopito
    Commented Jul 17, 2012 at 12:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .