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