cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: How to retrive 2 differentes pages in a single curl request...

From: Brock Noland <brockn_at_gmail.com>
Date: Mon, 14 Apr 2008 19:51:37 -0500

I think you want set cookie jar on the first connection:
  curl_setopt($ch, CURLOPT_COOKIEJAR, "/tmp/cookies.txt");

And cookie file on the second:
  curl_setopt($ch, CURLOPT_COOKIEFILE, "/tmp/cookies.txt");

Brock
http://bashcurescancer.com/

On Mon, Apr 14, 2008 at 7:39 PM, Lorenzo Ponce <lekronne_at_yahoo.com> wrote:
> Hi there...
>
> I'm trying to get some data from a website, which needs to be logged in. The
> loggin sessions are not persistent, so, if i close the curl script, then
> starting another one, the session would be expired...
>
> The login process is with a POST form (of course), then, the data must be
> retrived with GET (loading a standard page)... I suppose many of you habe
> done this, but i can't do it...
>
> What i have is this:
>
> $ch = curl_init();
> curl_setopt($ch, CURLOPT_URL, "url The login page");
> curl_setopt($ch, CURLOPT_POST, 1);
> curl_setopt($ch, CURLOPT_TIMEOUT, 15);
> curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
> curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
> curl_setopt($ch, CURLOPT_POSTFIELDS, "username=theUser¶passwd=thePass");
> $resultado1=curl_exec($ch);
> $error1=curl_errno($ch);
>
> curl_setopt($ch, CURLOPT_URL, "url The search with get params page");
> curl_setopt($ch, CURLOPT_POST, 0);
> curl_setopt($ch, CURLOPT_TIMEOUT, 15);
> curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
> curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
> $resultado2=curl_exec($ch);
> $error2=curl_errno($ch);
> curl_close($ch);
>
> echo $resultado2;
>
> I know this isnt elegant... so, if you can help with this...
>
> Thanks.
>
> ________________________________
>
>
> ¡Capacidad ilimitada de almacenamiento en tu correo!
> No te preocupes más por el espacio de tu cuenta con Correo Yahoo!:
> http://correo.espanol.yahoo.com/
Received on 2008-04-15