Re: Checking whether a website has loaded completely
Re: Checking whether a website has loaded completely
- Subject: Re: Checking whether a website has loaded completely
- From: MoJO <email@hidden>
- Date: Fri, 24 May 2002 13:58:24 -0600
Pardon my ignorance, but where do I look to learn more about the do script
(JavaScript) interface to IE?
I'd be interested in trying to do the same thing with file downloads (items
in IE's Download Manager window). I'm currently looking for the file to
change in the finder. It would be very useful to know the status of the
download (i.e., did the link fail, is it waiting, it's progress, etc).
To be a good scripting citizen here is the script I've been using:
on downloadURLAndWait(this_URL, the_File)
-- variable to check for download errors.
set fileNotFound to 0
set returnValue to 0
set retryCount to 0
my downloadURL(this_URL, the_File)
tell application "Finder"
set continueOn to false
repeat until continueOn false
-- wait for the file to begin downloading, or it may have failed
the download
if not (exists file (the_File)) then
log "File not found"
set fileNotFound to fileNotFound + 1
-- After retrying 2 times log it and go on.
if (retryCount 2) then
set returnValue to 1
exit repeat
-- After waiting for 20 seconds for the file to show up,
re-request the file.
else if (fileNotFound > 20) and (retryCount < 2) then
my downloadURL(this_URL, the_File)
set fileNotFound to 0
set retryCount to retryCount + 1
else
-- pause 1 second between checking if file exists
delay 1
end if
else
try
set file_info to info for alias the_File
--if busy status of file_info = true then
if file type of file_info starts with "bzy" then
log "File is busy"
delay 2
else if (file type of file_info = "JPEG") or (file type
of file_info = "TIFF") then
exit repeat -- don't set continueOn to true
else
set continueOn to open for access alias the_File
with write permission
end if
on error errTxt number errNum
if (errNum = -49) then
set continueOn to false
else
display dialog "Error: " & errTxt & return &
"Number: " & errNum
set returnValue to 1
end if
end try
end if
if quitting then exit repeat
end repeat
if continueOn = true then
close access continueOn -- to let other files access it.
end if
end tell
return returnValue
end downloadURLAndWait
Thanks,
jeff
>
From: email@hidden
>
Reply-To: email@hidden
>
Date: Fri, 24 May 2002 09:25:03 -0700 (PDT)
>
To: email@hidden
>
Subject: applescript-users digest, Vol 3 #497 - 15 msgs
>
>
Date: Fri, 24 May 2002 13:56:12 +0200
>
To: email@hidden
>
From: Peter Fischer <email@hidden>
>
Subject: Re: Checking whether a website has loaded completely
>
>
> set frontmost_window to item 1 of {ListWindows}
>
> set wait_flag to ""
>
>
>
> repeat until wait_flag = "complete"
>
> set CurrentURL to do script "document.location"
>
> set wait_flag to do script "document.readyState" window frontmost_window
>
> end repeat
>
>
This works fine if Internet Explorer is the foreground application
>
and the conntection to the internet is already active and I think it
>
does matter that the website is responding fast.
>
>
What I need is a sure solution that works with IE in the background
>
and takes care of slow internet connections.
>
>
Any other ideas?
>
>
--
>
Peter Fischer
>
Fischer-Bayern
>
"The source for german AppleScripters"
>
http://www.fischer-bayern.de
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.