• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: curl equivalence
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: curl equivalence


  • Subject: Re: curl equivalence
  • From: "John R." <email@hidden>
  • Date: Thu, 27 Oct 2005 16:31:48 -0400

On Thu, 27 Oct 2005 00:06:07 kai said:

>Another relatively simple approach using Safari...

You are following the same logical path that I did in developing my own handler. This is what I found after trial and error:

(1) Change of document name indicates the start of a load, NOT the completion. Only DOM readyState indicates completion, and even that sometimes fails for (thankfully) rare pages involving frames. Thanks to Gary for explaining the frames thing on an earlier posting: something to do with Microsoft...

(2) Just asking for the document name to soon after setting the url will wipe out the url for some reason. This seems to occur when my own machine (not the internet) is slow. However, asking the WINDOW name always works fine and serves the same purpose.

Compare your code to mine own. They are pretty close:

Yours:
> to getHTML from tgtURL
>      set pageLoading to false
>      tell application "Safari"
>          if not (exists document 1) then make new document
>          tell document 1
>              set URL to tgtURL
>              repeat 100 times
>                  if pageLoading then
>                      if name does not start with "Loading" then
> return source
>                  else
>                      set pageLoading to name starts with "Loading"
>                  end if
>                  delay 0.2
>              end repeat
>          end tell
>      end tell
>      error "Failed to open page."
> end getHTML

Mine:
> to getHTML from tgtURL
> tell application "Safari"
> set URL of document 1 to myURL
> set name of window 1 to "Waiting to Start!!!"
> repeat until name of window 1 does not contain "Waiting to Start!!!"
> delay 0.5 -- no error handling needed: it will always happen.
> end repeat
> set n to 0
> repeat 100 times
> delay 0.5
> set r to ¬
> (do JavaScript "document.readyState" in document 1 of window id winID)
> if r = "complete" then
> return source of document 1
> end if
> end repeat
> end tell
> error "Failed to open page."
> end getHTML




_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: curl equivalence
      • From: kai <email@hidden>
  • Prev by Date: Re: Placing long URLs in email
  • Next by Date: Re: curl equivalence
  • Previous by thread: Re: curl equivalence
  • Next by thread: Re: curl equivalence
  • Index(es):
    • Date
    • Thread