Automate download of links

I want to be able to download all the files from the links on a webpage but the links are embedded in a javascript:open new command. Would it be possible to give me some hints as to how to write a script which would automate the download of the files behind the links. The web URL is

http://searchwww.sec.gov/EDGARFSClient/jsp/EDGAR_MainAccess.jsp?search_text=tender%20AND%20offer&sort=Date&formType=1&isAdv=true&stemming=true&numResults=10&queryCo=inhibitex&fromDate=01/17/2012&toDate=01/17/2012&numResults=10

Many thanks

You could use a script like this one:


tell application "DEVONagent"
	set theBrowser to browser 1
	set theSource to source of theBrowser
	set theURL to URL of theBrowser
	
	set cnt to (do JavaScript "document.links.length" in theBrowser) as integer
	set i to 0
	repeat while i < cnt
		set theLink to do JavaScript "document.links[" & (i as string) & "].href" in theBrowser
		if theLink begins with "javascript:opennew('" then
			set od to text item delimiters of AppleScript
			set text item delimiters of AppleScript to "'"
			set theLink to (text item 2 of theLink) as string
			set text item delimiters of AppleScript to od
			add download theLink referrer theURL
		end if
		set i to i + 1
	end repeat
end tell

Thank you - that worked really well.