Is it possible to open multiple URLs on the same page

3,609 views
Skip to first unread message

Dahong Tang

unread,
Jul 6, 2013, 12:55:50 AM7/6/13
to phan...@googlegroups.com

Hi,

The example, render_multi_url.js (see link below), opens multiple urls by creating a new page for each URL, i.e., open one URL per page and do this multiple times. I am wondering if it is possible to open multiple URLs using the same page. If so, could someone please give an example? Thanks!

https://github.com/ariya/phantomjs/blob/master/examples/render_multi_url.js

James Greene

unread,
Jul 6, 2013, 8:32:54 AM7/6/13
to phan...@googlegroups.com

Yes, just call `page.open` again with a new URL once you're done processing the previous page.

Sincerely,
   James Greene

--
You received this message because you are subscribed to the Google Groups "phantomjs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to phantomjs+...@googlegroups.com.
Visit this group at http://groups.google.com/group/phantomjs.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Dahong Tang

unread,
Jul 6, 2013, 9:15:05 AM7/6/13
to phan...@googlegroups.com
Thanks James. Is it possible make calls to page.open sychronously, or in sequence, without nesting the 2nd call inside the first? If so, can you please give an example?

James Greene

unread,
Jul 6, 2013, 9:19:40 AM7/6/13
to phan...@googlegroups.com

No, not possible. The closest you'll get to something that LOOKS like a synchronous API is to use a higher order library on top of PhantomJS. I highly recommend CasperJS, or you can use the built-in PhantomJSWebDriver (GhostDriver) if you already use a Selenium or WebDriver API.

Sincerely,
   James Greene

Reply all
Reply to author
Forward
0 new messages