Mozilla Automated Website Screen Grabber

⏰ Old Post

This post is over 14 years old - it might be slightly outdated and consigned to the history books.

We have a requirement to do some screen grabbing and whilst there’s plenty of solutions for manual screen grabs there’s not much in the way of availability for automated screen grabs, as in, you feed an application a list of websites you want to get screenshots of and walk away from the computer.


ScreenGrabber in Action

Most of the examples that do exist are Internet Explorer based solutions. We’d rather not use Internet Explorer as the automated system might come across a website that exploits vulnerabilities in IE, so we wanted to use Firefox/Mozilla or a Chrome based solution. There are plenty of screenshot widgets for Firefox which is a great place to start.

So to give something back to the community we’re offering up some code we use in-house for a new project we are working on and we believe it may be the only XUL based automated screen grabber available at the moment.

Issues we had to Overcome to create an Automated Screen Grabber

1. Browser vulnerabilities – we didn’t want to use an Internet Explorer based solution so we opted for a Mozilla based solution using XULRunner.

2. Prompts – alert boxes, confirm boxes all sorts of modal dialogs can stop the automated process in its tracks and require a user to push a button. Using XULRunner and a modified version of Selenium’s promptService.js we managed to overcome this problem.

3. Flash – Typically flash will appear as a white box when the screenshot render happens if it’s “wmode” is not set to “transparent” so we actively change this when the page loads.

Flash does not render unless there’s an active window running, which is annoying especially it you run this on a remote desktop session (if you close the RDP window flash will not render on the screenshot grabber). To get around this is not too difficult and is explained later.

4. Events not Firing – Waiting for the page load to complete is not always accurate, we’ve got around this by waiting a maximum amount of time for a page to load and then just skipping to the next entry if no page load event fires.

Overcoming Flash not Rendering

Flash requires a “screen” to render, if there’s no active session, such as disconnected remote desktop session, Flash will appear as white boxes in your screenshots. To get around this install VNC Server and VNC Viewer, connect to a remote desktop session on your server and then open VNC Viewer to the local machine and run the application in the VNC Viewer window. The VNC Viewer application will keep alive when you disconnect the RDP session and continue to render Flash.

How to Install and Licence Details

The code for this application is far from perfect, it is basically built from a trial and error process so don’t expect the source code to be amazingly formatted and documented. You will need to do the following to get the application to work -

1. Install Firefox (not sure if you actually need to do this but we do it anyway to Install Flash for Firefox)
2. Install Flash for Firefox (or not if you don’t want Flash to render)
3. Install XULRunner
4. Register XULRunner with – xulrunner -register-global
5. Create a directory at c:\imgout \
6. Create a list of domains you want to screengrab, seperate them each with a new line and save to c:\domains.txt, for example-

google.com
altavista.com
mcdonalds.com

7. Run xulrunner application.ini -file c:\domains.txt
8. Watch as c:\imgout\ starts filling up with PNG’s.

Note this guide is for Windows, however the code should be cross-platform with a bit of modification to file paths in the mybrowser.js file in the package.

Download ScreenGrabber-1.0.zip 10KB

This is released under Apache 2.0 License.

About

BuiltWith® is a website profiler tool that tells you what a website is Built With.

Recent Posts