Finished my tool and its here to share, alter, improve upon or destroy

So, first I gotta say thanks to everyone who helped me along in finding the bits and pieces to this. This has been a great learning process. Basically, this script extracts a certain chunk of data from the XML and then performs a search within the listed URLs. The only problem was AMG is a bugger to work around (great resource tho!).
If anyone sees anything they don’t like, please feel free to comment. I’m here to learn and help when and if I can.
Again, thanks to everyone who helped with all my questions. I know I’ll have more :smiley:


tell application "Safari"
	set allXML to source of document "Confidential_Window_Name"
	set the clipboard to allXML
end tell


--extracting the album title from XML
setTID("Playlist Title")
set albumTitle to (text item 2 of allXML) as string
setTID("\"PageWrapper")
set albumTitle to (text item 1 of albumTitle) as string

setTID1("value=\"")
set albumTitle2 to (text item 2 of albumTitle) as string
setTID1("\" name=")
set albumTitle2 to (text item 1 of albumTitle2) as string


to setTID(newTID)
	set AppleScript's text item delimiters to {newTID}
end setTID

to setTID1(newTID)
	set AppleScript's text item delimiters to {newTID}
end setTID1


set the clipboard to albumTitle2

--get those URLs going! (General)
set URL1 to "http://www.cduniverse.com/sresult.asp?HT_Search=TITLE&HT_Search_Info=" & albumTitle2 & "&image.x=0&image.y=0&cart=668675610&style=music&altsearch=yes"
set URL2 to "http://www.google.com/products?num=100&hl=en&q=" & albumTitle2 & "+CD&um=1&ie=UTF-8"
set URL3 to "http://www.amazon.com/gp/search/ref=sr_adv_m_pop/?search-alias=popular&unfiltered=1&field-keywords=&field-artist=&field-title=" & albumTitle2 & "&field-label=&field-binding=&sort=relevancerank&Adv-Srch-Music-Album-Submit.x=0&Adv-Srch-Music-Album-Submit.y=0"
set URL4 to "http://www.allmusic.com"

tell application "Safari"
	activate
	tell application "System Events"
		tell process "Safari"
			
			click menu item "New Window" of menu "File" of menu bar 1
			open location URL1
			my new_tab()
			open location URL2
			my new_tab()
			open location URL3
			my new_tab()
			open location URL4
		end tell
	end tell
end tell

-->This is where the Wait_for_Page to load script goes.  
if page_loaded(20) then
	tell application "Safari"
		do JavaScript "document.forms['search']['search_txt'].focus()" in first document
		tell application "System Events"
			tell process "Safari"
				keystroke tab
				keystroke tab
				keystroke "al"
				keystroke tab using shift down
				keystroke tab using shift down
				keystroke albumTitle2
				keystroke tab
				keystroke return
			end tell
		end tell
	end tell
else
	display dialog "AMG took too long, so I stopped trying..." buttons {"I didn't care anyways.", "Good for you."} cancel button "I didn't care anyways." default button "Good for you."
end if


-->Waiting for page to load routine
on page_loaded(timeout_value) -- in seconds
	delay 2
	repeat with i from 1 to timeout_value
		tell application "Safari"
			if name of current tab of window 1 is not "Loading" then exit repeat
		end tell
		delay 1
	end repeat
	if i is timeout_value then return false
	tell application "Safari"
		repeat until (do JavaScript "document.readyState" in document 1) is "complete"
			delay 0.5
		end repeat
	end tell
	return true
end page_loaded

-->Opening new tab routine
on new_tab()
	tell application "Safari" to activate
	tell application "System Events"
		tell process "Safari"
			click menu item "New Tab" of menu "File" of menu bar 1
		end tell
	end tell
end new_tab

Model: Dual 2 GHz PowerPC G5
AppleScript: 2.2
Browser: Safari 523.10.6
Operating System: Mac OS X (10.5)

Hi,

as you’re using obviously Safari 3, the routine to open a new window and open the tabs
can be written without GUI scripting, because Safari 3 is able to script tabs.


.
-- get those URLs going! (General)
set URLlist to {"http://www.cduniverse.com/sresult.asp?HT_Search=TITLE&HT_Search_Info=" & albumTitle2 & "?.x=0?.y=0&cart=668675610&style=music&altsearch=yes", ¬
	"http://www.google.com/products?num=100&hl=en&q=" & albumTitle2 & "+CD&um=1&ie=UTF-8", ¬
	"http://www.amazon.com/gp/search/ref=sr_adv_m_pop/?search-alias=popular&unfiltered=1&field-keywords=&field-artist=&field-title=" & albumTitle2 & "&field-label=&field-binding=&sort=relevancerank&Adv-Srch-Music-Album-Submit.x=0&Adv-Srch-Music-Album-Submit.y=0", ¬
	"http://www.allmusic.com"}

tell application "Safari"
	make new document
	set URL of document 1 to item 1 of URLlist
	tell window 1
		repeat with oneURL in rest of URLlist
			make new tab with properties {URL:oneURL}
		end repeat
	end tell
end tell

-->This is where the Wait_for_Page to load script goes. 
.

the new_tab() handler is no longer needed