Getting applescript to pull file name from html file??

I am trying to make a script that will read from a website the file name of a file that updating on a regular basis (in this case a quicktime movie). The website will not let me download with out using a web browser since it uses cookies to make sure I am logged in. Otherwise I would probably call curl or the URL download app.

My question is, is there a way to grab the filename of the movie file from the html page so that I can use this name to pass to safari to download?

Here is an example of what the quicktime movies file name will look like in the html (the path of the file is always static so I do not need it.):

<embed src="http://www.somesite.com/812.mov

Here is an example of code i made to pass the file name to the download window of safari to make it download:
tell application “Safari”
activate
end tell
tell application “System Events”
click menu item “Downloads” of menu “Window” of menu bar item “Window” of menu bar 1 of process “Safari”
set the clipboard to “http://www.somesite.com/812.mov
click menu item “Paste” of menu “Edit” of menu bar item “Edit” of menu bar 1 of process “Safari”

end tell

The otherthing that might be possible it to have a counter add 1 to the file name of after each succesful download and keep trying to download till it is succesfull. I am not sure if it is possible for safari to tell applescript if a file has downloaded or got a 404 error.

Thanks!

-Adam

I would give “curl” a try before using Safari, as it is much more powerful than a web browser (it is in fact a web browser on steroids). It supports cookies, referrer, POST data and much more things.
This is a brief example:

set userAgent to "Mozilla/4.0"
set referrer to "http://foo"
set theCookies to "cookie1=value1;cookie2=value2"
set URLEncodedFormData to "foo=my%20name&bar=my%20bar"
set URLTarget to "http://bar"
do shell script "curl -A " & quoted form of userAgent & " -e " & quoted form of referrer & " -b " & quoted form of theCookies & " -d " & quoted form of URLEncodedFormData & space & quoted form of URLTarget

Is irrelevant if you know that

Your idea of

sounds easy enough. How often is the site updated? If it’s every 24 hours you could create a script that increased the number in the path name by one, and download every 24 hours. I did something similar to this in Explorer, and it works fine.
SC