curl-users
Re: Post request
Date: Fri, 16 Sep 2005 06:42:39 -0500
On 9/16/05, Daniel Stenberg <daniel-curl_at_haxx.se> wrote:
>
> On Fri, 16 Sep 2005, Gerard Brul wrote:
>
> > - I send a POST request to a HTTPS server
>
> > - I receive a page back with information and also containing 'data' I
> must
> > reuse to get the next page back
> >
> > How can I get this data from the html-page and reuse it in the next curl
> > request?
>
> By using libcurl. There is simply no way to do this with the command line
> tool. Pick a binding for your favourite script language!
Bet you a beer?? My favourite curl binding is the Bourne shell:
curl <bunch of arggghhs> -o htmlfile https://secure.server.com
stuff=`grep XXX htmlfile`
curl <bunch of arggghhs> -d $stuff -o htmlfile2 https://secure.server.com
etc. The 'grep' stage is usually a lot more complicated in my world - it
really depends what you need to extract and pass back. I've modified
formfind.pl slightly to hand hand a form like this:
-d var1=xxx
-d var2=xxx
<action url>
so I can do:
stuff=`cat htmlfile | formextract.pl | sed -e 's/userid=/userid=joe.cool' -e
's/passwd=/passwd=mysecret'`
curl $stuff -o htmlfile2 http://....
Sometimes the form action needs fixing up too, which involves more sed and
trapping the effective_url, which ain't always pretty...
Ralph Mitchell
Received on 2005-09-16