Re: curl equivalence
Re: curl equivalence
- Subject: Re: curl equivalence
- From: Christopher Nebel <email@hidden>
- Date: Wed, 26 Oct 2005 11:56:08 -0700
On Oct 25, 2005, at 12:55 PM, John R. wrote:
I am glad that someone brought up the subject of curl...
I am (still) looking for the easiest and most reliable way to
simply download the HTML from a website. Sounded simple enough to
me, at first.
Curl would be wonderful, if I could only make it work! This is easy
-- do shell script "curl http://www.apple.com". However, I
subscribe to secure databases that hate curl and automation, and I
could never figure out how to get the password, user-agent,
cookies, etc to work right. Besides, all that stuff is set up
perfectly well already in my Safari browser. Also, curl is blind,
and it is nice to be able to see visual feed back visiting the
websites.
Therefore, Applescript is ideal for automating Safari to do it
right. However, the problem is knowing when the HTML is ready for
capture, without waiting forever++
I offer you guys the following code, which works MOST of the time
(eg. a frames problem that Gary clarified on another posting.)
Questions:
Why should it have to be this damn complicated?
Any ideas for doing it better?
If you don't mind using Objective-C, then you can get essentially
ideal results. (I'd point out that using Safari for your visual
feedback has two problems: one, many people regard a full-size window
popping up to be annoying; two, if they were trying to use Safari at
the same time as your program, at least one will not be happy.)
Essentially, you want to use one of the NSURL family -- these are
tied into the same foundation that Safari uses, so you get the same
cookie jar. Depending on the API you use, you can get different
effects, but the one that's the simplest and most "correct" (i.e.,
requires the least post-processing of the answer) is +
[NSURLConnection sendSynchronousRequest:response:error:]. You do
have to check the response status code yourself, though.
--Chris Nebel
AppleScript and Automator Engineering
_______________________________________________
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