How to search and play a Spotify track using AppleScript:

set savedClipboard to (the clipboard as string)

tell application "System Events"
	tell process "Spotify"
		open location "spotify:search:artist:rise against title:collapse"
		delay 1
		keystroke "l" using command down
		delay 0.1
		keystroke "	"
		delay 0.1
		keystroke "	"
		delay 0.1
		click menu item 5 of menu 1 of menu bar item 4 of menu bar 1
	end tell
end tell

set spotifyHTTPURI to (the clipboard as string)
delay 0.1
set the clipboard to savedClipboard
set AppleScript's text item delimiters to "/"

set spotifyURI to "spotify:track:" & (spotifyHTTPURI's text item 5)
open location spotifyURI