Applescript guru needed please…

Hi all,
I am working on a project to create photo albums on a website, and all my images are currently on kodakgallery.com. I am trying to use automator to get all the full-size images from the site, but since the images reside on a different server the GET LINKED IMAGES option doesn’t work. I found this nifty little script that lets me downbload the thumbnails:

on run {input, parameters}
	tell application "Safari"
		
		set imageURLsList to {} as list
		set frontDoc to the front document
		-- the domain of the page - we only want external image links 
		set domainRoot to do JavaScript "document.domain" in frontDoc
		-- the number of images in the front document 
		set numberOfImages to do JavaScript "document.images.length" in frontDoc
		
		repeat with i from 0 to (numberOfImages - 1)
			set the JSCode to "document.images[" & i & "].src"
			set thisImageSRC to do JavaScript the JSCode in frontDoc
			if thisImageSRC does not contain domainRoot then
				log ("external image - " & thisImageSRC)
				copy thisImageSRC to end of imageURLsList
			end if
			
		end repeat
	end tell
	
	return imageURLsList
end run

The problem is that I need the full size images, not the thumbs! Can anyone tell me how to modify the code to tell it to get the link to the page that opens when you click the thumbs, rather than the thumbs themselves? Does that make sense? Thanks!!!
Billy

Model: iMac G5
Browser: Safari 417.9.3
Operating System: Mac OS X (10.4)

Hi spacedawg,

I don’t know too much about javascript and html, but you might try this. Get the address of the image (thumbnail) and check all link tags for the image address. html is written in many ways so this might not work. Here’s an example:


tell application "Safari"
	set d to front document
	set image_links to {}
	-- get address of thumbnail
	set image_src to (do JavaScript "document.images[0].src" in d)
	-- get tag of link
	-- here, you would check tags of every link until
	-- you find the one that contains the thumbnail address
	set link_tag to (do JavaScript "document.links[0].text" in d)
	-- you might parse the text better than in the following comparison
	-- it just checks for inclusion
	if link_tag contains image_src then
		-- get address of link
		set link_href to (do JavaScript "document.links[0].href" in d)
		-- add it to list
		set end of image_links to link_href
	end if
end tell
image_links

I just tested this with a page I made in Netscape Composer that has one image link. For your script you would repeat through all images. For each image, you need to repeat through all links until the correct link is found and add that link to your links list.

I have a bad connection to internet, so having a hard time testing.

Edited: your imageURLsList contains the addresses you should look for in the links tags. These are your “external” images.

gl,

Kel,
Thanks so much for your help! That script would be exactly what I needed, but there’s one issue. The links from the thumbnails open a new kodakgallery page, and the image I want is on that new page, and check out the link:

http://www.kodakgallery.com/PhotoView.jsp?&collid=59739134110.38651530410.1150086377825&photoid=268501651305&folderid=0&view=2&page=1&sort_order=&albumsperpage=&navfolderid=2005

If the thumb linked drectly to an image filename I think we’d be in good shape. But as you can see, the image filename does not appear in the link. Here is an example filename:

http://images.kodakgallery.com/photos1572/3/51/26/62/68/3/368622651305_0_ALB.jpg

Kodak is really making this hard! There are like 10 albums I need to download and each has a few hundred pics in it! ARGHH!! THANKS AGAIN, you’re the bomb!!!

Hi spacedawg,

Can’t connect to your link, because you need an account and a cookie. I would check out the links and see if there is anything in the text that connects to the thumbnail name or address. They have made it hard! I suppose they have to show advertisements.

gl,

Sometimes site’s obscure the direct URL for the image to prevent this sort of thing. But look on this forum for some CURL examples. You can often get the html for the page with your full-sized photo and them look in there to find the image link if the html follows a pattern you can parse.