Skip to content

Instantly share code, notes, and snippets.

@sansumbrella
Created February 22, 2010 17:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sansumbrella/311286 to your computer and use it in GitHub Desktop.
Save sansumbrella/311286 to your computer and use it in GitHub Desktop.
Batch website screenshots using Safari
(*_*)
(* Navigates to each page and takes a screenshot *)
(* Combined a screenshot script -- http://www.macosxhints.com/article.php?story=20030115080027106 -- with some javascript *)
set save_location to (choose folder with prompt "Choose where to save screenshots")
set base_url to "http://sansumbrella.com/writing/page/"
set first_page to 1
set last_page to 5
set filename to "screenshot-"
tell application "Safari"
activate
do JavaScript "window.resizeTo(1200, 824);" in document 0
do JavaScript "window.moveTo(0,0);" in document 0
end tell
repeat with id from first_page to last_page
tell application "Safari"
do JavaScript "window.location.href = '" & base_url & (id as string) & "/'" in document 0
--let the page load
delay (4)
do shell script "screencapture " & quoted form of POSIX path of save_location & filename & (id as string) & ".png"
delay (1)
end tell
end repeat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment