cURL / Mailing Lists / curl-users / Single Mail

curl-users

Curl and cookies

From: Tig <tig_at_online.be>
Date: Sat, 2 Feb 2008 15:11:17 +0100

Hi all,

I am pretty new to curl and made some perl script using curl to log on a
site and get some data.

The site is set so that I first need to log on before I can get the data; so
I use following code to create cookie files and then I get my data using the
second code.

Code 1
---------------------
$c = `\"$dir\"/curl/curl.exe -s -A "Mozilla/4.0" -c cookies.txt -d
"usrname=xxx&uemail=xxx\@xxx.be&peeword=xxxx&submit=Login"
www.somewebsite.com/login.php`;
---------------------

Code 2
---------------------
$cont = `\"$dir\"/curl/curl.exe -s -S -A "Mozilla/4.0" -b cookies.txt
www.somewebsite.com/somefile.php?jump=$i`;
---------------------

That $i is the pagenumber to get the data from ... this all runs in a loop
($i = 1 to 10)

I did find on the internet that you can work with comma seperated lists (for
example {1,2,3,4,5,6,7,8,910} of [1-10] instead of that $i; but that doesn't
seem to work ...

So now I make this work running both code in a loop, BUT the script makes me
login every time I change pages ($i) ... I there a way to make the
cookiefile stay alife longer than for 1 page visit, so I can set the
cookiefile creation code outside the loop; making the script much faster?

Greetz

Thierry
Received on 2008-02-02