applescript – Automator – Modify the results of Get Image URLs from Webpage

Spread the love


Advertisement

I'm trying to modify the results of a list of 30 items from “Get Image URLs on Webpage”.

Advertisements

For example:

"https://dspncdn.com/a1/media/236x/82/58/da/8258da274aa4b81ab00c9c92cf5bcf50.jpg",
  "https://dspncdn.com/a1/media/236x/4e/9a/75/4e9a75bec9041112751ca2dd08a45026.jpg",
  "https://dspncdn.com/a1/media/236x/33/83/46/338346575aa402b13cb778c9525018fb.jpg",

What I would like to do is replace “236x” with “originals”.

The problem is that the closest I can get eliminates the ” “, and line breaks, which renders makes Downloading impossible.

"https://dspncdn.com/a1/media/original/82/58/da/8258da274aa4b81ab00c9c92cf5bcf50.jpghttps://dspncdn.com/a1/media/original/4e/9a/75/4e9a75bec9041112751ca2dd08a45026.jpghttps://dspncdn.com/a1/media/original/33/83/46/338346575aa402b13cb778c9525018fb.jpghttps://dspncdn.com/a1/media/original/a1/4f/7b/a14f7b07c1fafb12fce1ccdd53b52e69.jpghttps://dspncdn.com/a1/media/original/30/42/64/304264157b118808f6702f82c043aa65.jpg

Etc.

Forgive me for being extremely noob. The code I'm using to make the change is:

on run {input}
    set input to replaceText("236x", "original", input as string)
end run

on replaceText(find, replace, textString)
    set prevTIDs to AppleScript's text item delimiters
    set AppleScript's text item delimiters to find
    set textString to text items of textString
    set AppleScript's text item delimiters to replace
    set textString to "" & textString
    set AppleScript's text item delimiters to prevTIDs
    return textString
end replaceText

I'm not sure of the right words to describe strings and paragraphs, truly noob, but I would guess that the preservation of each line in the paragraph might require something else entirely. Is it still a string if it has multiple lines?

Thanks in advance for any help can be given. I believe it's my final step to solving this.

Author: Subham

Leave a Reply

Your email address will not be published. Required fields are marked *