Capturing entire webpages into a FileMaker container field

Recently a client requested we capture webpages for them. As a marketing company recording evidence of the exposure they gained their clients is key requirement. They had for many years manually stitched screenshots together. While cheap this approach was incredibly time consuming, tedious and prone to mistakes.

Luckily the client were on OS X so I was able to use webkit2png. This funky little command line utility uses webkit to render an entire webpage. Really quite handy and very simple to use. The only other difficulty is getting FileMaker to run a command line script. Applescript is our saviour here. A calculated Applescript allows us to dynamically generate the command line.

Here is the FileMaker script:

Set Variable
[ $$kp_screengrab; Value:SCREENGRAB::__kp_ScreenGrab ]

Set Variable
[ $url; Value:Get(ScriptParamater) ]

Perform AppleScript
[ Calculated AppleScript:
“tell application \”Finder\”¶ do shell script \
“python /sbin/webkitToPNG/
-F -o “& SCREENGRAB::__kp_ScreenGrab & ” -D ” &
Right(Get ( TemporaryPath ); 1 + Length(Get( TemporaryPath )) – Position ( Get ( TemporaryPath ) ; “/” ; 1 ; 2 )) & ” ” & $url & “\”¶
end tell”

Set Variable
[ $file; Value:”image:”&Get ( TemporaryPath ) & $$kp_screengrab & “-full.png” ] Go to Field [SCREENGRAB::d_ScreenGrab ]

Insert Picture
[ “$file” ]

From the top we set a variable equal to the primary key of the record we are going to insert. This is used in the generation of the filename. We also set a variable to the ScriptParameter; this is used to pass teh URL into the script.

The perform applescript step uses the terminal to create a python command. The python command calls the webkit2png with various switches, the path to write the file and the URL. The switches are documented by typing ‘python /path/to/webkit2png –help’ in terminal. This has the added advantage of ensuring you have the path correct.

All in all a pretty easy bit of code once the R&D has been done. The biggest thing to take away is how easy it is for FileMaker to interact with the command line and command line utilities.

Damian Kelly

Damian has been a database developer with Linear Blue since 2007. During this time he has developed complex FileMaker solutions in a broad range of industries from Finance and Investment to Manufacturing to New Media Promotion. Damian graduated in Production Engineering from the University of Hertfordshire in 1996, attained his Masters of Engineering from Kingston University in 1997 and MBA from Heriot Watt in 2006. He holds certification in FileMaker versions 7 through 12 and in Oracle MySQL 5.

More Posts - Website

1 thought on “Capturing entire webpages into a FileMaker container field”

Leave a Reply