[olug] automating web page screenshots

John Hobbs john at velvetcache.org
Fri Mar 22 03:28:50 UTC 2013


It also has a built in (though sluggish & likely dangerous) HTTP server.

https://github.com/ariya/phantomjs/wiki/API-Reference-WebServer

If you are running a bunch of screenshots off the same site this can come
in handy because it keeps a cache and you don't have to wait
for PhantomJS to come up for every screenshot.

I'm using it to do a screen capture of a profile when it is created on Pack.

http://usercontent.packlove.com/profiles/86b18a4b043a7b9dc641180a206526e7e068f80f.jpg

I have a queue job which asks the long-running PhantomJS HTTP server for a
profile, which renders it and returns it as a PNG that the queue worker
stores out to S3.   It's pretty neat, and it's worked great for me so far,
my PhantomJS server hasn't been leaky or fallen over, and it's been up in
production for several weeks now.

If anyone is interested in the code, I could sanitize out my specifics and
post it somewhere.

Also, check out http://casperjs.org/ which is a layer on top of PhantomJS
for testing and other goodies.




- John Hobbs

john at velvetcache.org

http://www.velvetcache.org/


On Wed, Mar 13, 2013 at 9:03 PM, Rob Townley <rob.townley at gmail.com> wrote:

> Since it uses JavaScript....  To make C code better, one may use lint.  For
> JavaScript, NickNisi mentioned his precommit hook that calls jsLint and
> prevents commit when errors found.
>
> http://nicknisi.com/blog/blog/2012/11/12/lint-javascript-on-commit/
> On Mar 13, 2013 4:24 PM, "Jeff Hinrichs - DM&T" <jeffh at dundeemt.com>
> wrote:
>
> > That is cool.  I know the phantomjs is used by many to run e2e tests on
> > build bots and saw an AngularJS presentation the other day, where they
> were
> > using it to prerender js template pages into varnish to help with SEO.
> >
> > -Jeff
> >
> >
> > On Wed, Mar 13, 2013 at 4:16 PM, Adam Haeder <adam at adamhaeder.com>
> wrote:
> >
> > > Automating the creation of webpage screenshots used to be a giant thorn
> > in
> > > my side. I just stumbled across this project on github today that makes
> > it
> > > pretty simple:
> > > http://phantomjs.org/ - PhantomJS is a headless WebKit with JavaScript
> > > API.
> > > It has fast and native support for various web standards: DOM handling,
> > CSS
> > > selector, JSON, Canvas, and SVG.
> > >
> > > Howto:
> > > Step 1. Download the package from http://phantomjs.org/download.html.
> > > Compiled for CentOS 5.8 so you might not even have to compile it
> > yourself.
> > > Step 2. Extract: tar xvjf phantomjs-1.8.2-linux-i686.tar.bz2
> > > Step 3. Go to the examples directory: cd
> > > phantomjs-1.8.2-linux-i686/examples
> > > Step 4. Grab a screenshot of google.com: ../bin/phantomjs
> > ./rasterize.js "
> > > http://www.google.com" google.png
> > >
> > > Couldn't be easier
> > >
> > > --
> > > Adam Haeder
> > > adam at adamhaeder.com
> > >
> > > Check out my latest book: LPI Linux Certification in a Nutshell from
> > > O'Reilly: http://bit.ly/bvQQ0I
> > > _______________________________________________
> > > OLUG mailing list
> > > OLUG at olug.org
> > > https://lists.olug.org/mailman/listinfo/olug
> > >
> >
> >
> >
> > --
> > Best,
> >
> > Jeff Hinrichs
> > 402.218.1473
> > _______________________________________________
> > OLUG mailing list
> > OLUG at olug.org
> > https://lists.olug.org/mailman/listinfo/olug
> >
> _______________________________________________
> OLUG mailing list
> OLUG at olug.org
> https://lists.olug.org/mailman/listinfo/olug
>



More information about the OLUG mailing list