Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.