I needed to save web pages screenshots. The closest option to my initial environment was Fedora Linux 16 on Amazon EC2 is python-webkit2png.
To make it work on the headless server and render flashes I had to:
Get the base Fedora AMI running, I’ve selected the first one I’ve found (ami-7bf4c90f) and ran it as micro
rpm -ivh http://linuxdownload.adobe.com/adobe-release/adobe-release-i386-1.0-1.noarch.rpm
yum install flash-plugin
wget https://github.com/AdamN/python-webkit2png/zipball/master
unzip -x master
cd AdamN-python-webkit2png*
python setup.py install
And you should be ready to go
Test run it like this:
And you should see that it doesn’t render flash. Thing is you have no browser on the server so plugin directories where webkit expects to find them are not there. Create one and link the flash plugin:
redo the test above and you will see the flash rendering. but somehow –wait option doesn’t seem to work so the rendering doesn’t finish so you will only get progress bars when there is lots of data the initial swf pre-loads. It seems like a problem in webkit2png.py around line 219 (/usr/lib/python2.7/site-packages/webkit2png-0.8.2-py2.7.egg/webkit2png/webkit2png.py):
while time.time() < waitToTime and QApplication.hasPendingEvents():
QApplication.processEvents()
If there are no QApplication pending events the while will break out and will not wait. I am not sure what the problem really is but changing it to this:
while time.time() < waitToTime:
if QApplication.hasPendingEvents():
QApplication.processEvents()
Update: Another issue with flash.
Seems like the window is resized too late and flash doesn’t update its geometry thus creating 800×600 screenshots. This fix seems to make things work better:
in the WebkitRenderer.render(), resize the window just after the helper is created:
helper._window.resize( self.width, self.height )