PhantomJS on Windows Azure

2,199 views
Skip to first unread message

Brian Linden

unread,
Oct 9, 2012, 1:38:34 AM10/9/12
to phan...@googlegroups.com
Has anyone successfully used PhantomJS in Windows Azure.  It works great on the few tests that I've done locally, but I was wondering if anyone has had experience using it in Windows Azure (worker role).

I'd like to use it make screenshots of web pages.  Is it entirely "self-contained", or does it depend on any locally installed programs like Chrome or FireFox? Like I said, it works great locally, but I've got so much installed on my dev box I can't really tell if there are dependencies.

PS: Great library/program.  I've been thinking about all the options this now opens up for me, it's pretty exciting.

- Thanks

Ivan De Marino

unread,
Oct 9, 2012, 6:36:22 AM10/9/12
to phan...@googlegroups.com
The release binaries work on their own. No dependency on other browsers.

Hence, if Azure provides a "normal" windows runtime, I don't see why it shouldn't work nicely.

Let us know your findings ;)

--
 
 
 



--
Ivan De Marino
Coder, Technologist, Cook, Italian

blog.ivandemarino.me | www.linkedin.com/in/ivandemarino | twitter.com/detronizator

Ariya Hidayat

unread,
Oct 9, 2012, 9:41:54 AM10/9/12
to phan...@googlegroups.com
> I'd like to use it make screenshots of web pages. Is it entirely
> "self-contained", or does it depend on any locally installed programs like
> Chrome or FireFox? Like I said, it works great locally, but I've got so much
> installed on my dev box I can't really tell if there are dependencies.

This has been asked so many times, even on StackOverflow, that I don't
know what else we should do to clarify the situation. If one just
reads http://phantomjs.org/download.html, it clearly says:

"Note: For this static build, the binary is self-contained with no
external dependency. It will run on a fresh install of Windows XP or
later versions. There is no requirement to install Qt, WebKit, or any
other libraries."

Any suggestion on how to improve the wording or even on how to
encourage others to read that particular sentence will be very
welcomed!


Thanks!

Regards,

--
Ariya Hidayat, http://ariya.ofilabs.com
http://twitter.com/ariyahidayat

Ivan De Marino

unread,
Oct 9, 2012, 6:00:19 PM10/9/12
to phan...@googlegroups.com
I think we should consider starting selling t-shirt with that written on the back.
:)

--



Brian Linden

unread,
Oct 19, 2012, 3:07:22 PM10/19/12
to phan...@googlegroups.com
Nobody will argue I'm the sharpest guy, but I couldn't find it on StackOverflow (still can't):

I also found no mention of Azure here on the phanomtjs group.  

So in case anyone else stumbles upon this post, I did successfully get phantomjs working in a Windows Azure Worker Role.  It's one thing to read a line or two about "having no external dependencies", and another to have someone claim that they've actually got it working....so here it is.  I did get it working.

Hopefully someone finds this post.

James Greene

unread,
Oct 19, 2012, 4:24:02 PM10/19/12
to phan...@googlegroups.com
Ariya and Ivan were referring to the question about whether PhantomJS has any dependencies being on StackOverflow, etc.  Not referring to Azure.
~~James

Manny Lertpatthanakul

unread,
Nov 23, 2012, 9:29:39 PM11/23/12
to phan...@googlegroups.com
Thanks for confirming this, Brian.  I'm currently in the process of creating a similar solution as what you had described here and was worried because I'm not fully aware of how Azure handles different processes and whether one connection hosting phantomjs would interfere with another.  I'll move forward with a little more confidence, so your post has been of value for at least one other developer.

Regards,
Manny

Peter Andreas Moelgaard

unread,
Jul 1, 2013, 4:10:19 PM7/1/13
to phan...@googlegroups.com
Brian, me too, I can't find any references to this, and I'm now stuck and can't get it to work... do you have some pointers or some advice you can share as to how you went about getting it to work ?

Thanks in advance,
Peter

Morgan Intrator

unread,
Jun 3, 2014, 2:07:43 PM6/3/14
to phan...@googlegroups.com, ad...@petermolgaard.com
Brian, I also would love to see how you pulled it off. I'm trying to use node-phantom and node-phantom-simple modules to get a web job working (but have also tried it on a web site) and can't get it working. Created an issue on kudu: https://github.com/projectkudu/kudu/issues/1194#issuecomment-44986749

Thanks,

-Morgan

Brian Linden

unread,
Jun 3, 2014, 2:16:07 PM6/3/14
to phan...@googlegroups.com, ad...@petermolgaard.com
I got it working in an Azure Worker Role.
I ended up doing something like this:

------------------------------------------------------------------------

var info = new System.Diagnostics.ProcessStartInfo() {
    FileName = exePath,
    Arguments = string.Format(@" {0}\rasterize.js {1} {2}", appDirectory, urlToWebpage, outputPath),
    UseShellExecute = false,
    RedirectStandardError = true,
    RedirectStandardInput = true,
    RedirectStandardOutput = true,
    CreateNoWindow = true
};

string errorFromExe = string.Empty;

using (System.Diagnostics.Process proc = System.Diagnostics.Process.Start(info)) {

    errorFromExe = proc.StandardError.ReadToEnd();

    proc.WaitForExit();

}

------------------------------------------------------------------------

I then log any errors (errorFromExe) and do something with the outputted image.
Hopefully this helps someone else.


Morgan Intrator

unread,
Jun 3, 2014, 2:29:06 PM6/3/14
to phan...@googlegroups.com, ad...@petermolgaard.com
Thanks Brian,

I'm in Node but appreciate your help anyway!

John Chohon

unread,
Feb 13, 2020, 2:31:42 PM2/13/20
to phantomjs
thanks dude
Reply all
Reply to author
Forward
0 new messages