• Welcome to AcornDomains.co.uk, a friendly community for UK domain investors, developers and anyone interested in domain names.

    Whether you're looking to buy or sell domains, learn more about the UK domain market, get feedback on your names, or simply chat with other domainers, you're in the right place. AcornDomains has been bringing together people from across the UK domain industry for many years, from complete beginners to experienced investors.

    Have a look around, join the discussions and, if you haven't already, create a free account and introduce yourself.

Wanted: Service Tweak this apple script please

Joined
May 10, 2007
Posts
1,972
Reaction score
288
Hi,

I'm trying to take screen grabs of a list of URLs.

I'm doing it on a local machine - to ensure the grabs all look perfect.

I've found an apple Script for Mac which does the job perfectly:
https://mac.appstorm.net/general/ap...y-create-screenshots-from-a-list-of-websites/

The only disadvantage is that it names the files webshot-1, webshot-2, rather than the URL of the page that the screen grab is of.

I've had a little play with this - but to no avail.

If anyone can help, that would be great.

Thanks, Phil
 
this works i think :

Code:
--Variables
set whichUrl to 1
set fileNames to "webshot"
set filename_text to ""

--Get Number of URLs
tell application "TextEdit"
    set theCount to the count of paragraphs of front document
end tell

--Repeat this for every URL
repeat theCount times
  
    --Get the next URL
    tell application "TextEdit"
        set currentUrl to paragraph whichUrl of front document as text
    end tell
  
    --Open the URL in Safari
    tell application "Safari"
        activate
        set the URL of document 1 to currentUrl
      
        --Wait until it loads, then take a screenshot
        delay 5

        --set current url as variable to be able to strip text
        set the filename_text to currentUrl
      
        set filename_text to ((characters 8 thru -1 of filename_text) as string) --trim first characters of current url
        set filename_text to ((characters 1 thru -6 of filename_text) as string) --trim last chracters of current url
      
        set picPath to ((POSIX path of (path to desktop)) & fileNames & "-" & filename_text & ".jpg") as string
        do shell script "screencapture -tjpg " & quoted form of picPath
    end tell
  
    --Increase the counter for next time
    set whichUrl to whichUrl + 1
end repeat

play around with the character trim bit if your using mostly co.uk or whatever so your not writing full stops in the file name
 
Last edited:
Top Bottom