This can absolutely be done, it just requires a little more than PHP to make this happen. I have an application written in PHP that takes snapshots of websites at regular intervals. This is a little tricky to do, but here are the steps I took on a Linux machine:
- Install Xvfb (or vnc server) to emulate an X Windows session in memory. Run Xvfb on the display: 1
- Install Firefox
- Install imagemagick
- Create a bash script to launch Firefox at the desired URL. My looked like this:
.
#!/bin/bash DISPLAY=:1 firefox & sleep 2s DISPLAY=:1 firefox -kill-all & sleep 1s DISPLAY=:1 firefox -url $1 & sleep 5s DISPLAY=:1 import -window root /var/www/images/screenshots/$2.png
.
exec ('sh ../scripts/screencap.sh ' . $url . ' ' . $file_name);
The hardest part for me was to get the browser to be in full screen when the screenshot took place. Since you cannot access the browser directly, you need to configure everything through the Firefox configuration files, which may take some time to understand.
Useful links to help you get started:
http://semicomplete.com/blog/geekery/xvfb-firefox.html http://www.webmasterworld.com/forum21/9182.htm
Andy Baird Dec 23 '09 at 18:29 2009-12-23 18:29
source share