How do I get a frame source from Safari?

my college streams recorded lectures online but i receive the error message

The page �IVLE Webcast Lectures� has content of MIME type �application/x-oleobject�. Because you don�t have a plug-in installed for this MIME type, this content can�t be displayed.

when i try running with safari. i managed to get around this by searching for the url link to the .asx file in the source manually(ctrl-f), then running the link directly in safari. im trying to write an applescript to automate this process, but run into a couple of problems.

  1. the page uses frames. how do i get a frame source?
  2. how can i extract the url, in the format “http:// … .asx” fr the source?

This is a quick sample:

tell application "Safari"
	set allPages to paragraphs 1 thru -2 of (do JavaScript "if (frames.length == 0) return top.location + '\r';
urls = '';
for (i=0;i<frames.length;i++){
	urls += frames[i].location + '\r';
}
urls" in document 1)
end tell

set possibleASX to {}
repeat with i in allPages
	set pageSource to (do shell script "curl " & i)
	repeat
		try
			set x to offset of ".asx" in pageSource
			set x to text (x - 100) thru x of pageSource --> get a chunk of text before coincidence
			--> attemp to extract src
			set end of possibleASX to (text -((offset of """ in (reverse of (x's items) as text)) - 1) thru -1 of x) & "asx"
			--> go to next coincidence
			set pageSource to text x thru -1 of pageSource
		on error --> no more asx
			exit repeat
		end try
	end repeat
end repeat
possibleASX --> eg, {"stuff.asx"}, or {"http://www.stuff.com/file.asx"}, or {"../../file.asx"}

This code assumes that the embeds are formatted as «… src=“file.asx”».

This would be a more quick and direct way to do it, using IE, which supports the “embeds” object:

tell application "Internet Explorer"
	set allPages to (do script "asxFiles=new Array();
if (frames.length == 0) {
	explorePage(window);
} else {
	for (i=0;i<frames.length;i++){
		explorePage(frames[i]);
	}
}
if (asxFiles.length == 0){
	'';
} else if (asxFiles.length == 1){
	asxFiles;
} else {
	join(asxFiles, '\r');
};
function explorePage(page){
	for (i = 0; i<page.document.embeds.length; i++){
		embedSRC = page.document.embeds[i].src;
		// add embed src if ends with .asx
		if (embedSRC.indexOf('.asx') != -1) asxFiles[asxFiles.length] = embedSRC;
	}
}")
end tell

(if the contents are embedded with a single “” tag, without “”, the code will fail)
But, most probably, if you use IE you won’t receive the “content can’t be displayed” error…