cURL / Mailing Lists / curl-users / Single Mail

curl-users

curl and cookies

From: Pedro Kröger <kroegerlistas_at_pedrokroeger.net>
Date: Wed, 28 Feb 2007 14:32:35 -0300

Hi,

I have been using curl for some time (it's an incredible useful tool!)
but now I have a problem:

I want to login to a site to download some data (naturally I have a ID
and password, and the data is mine ;-)

here is the code to send the data to the login form:

curl -A "Mozilla/4.73 [en] (X11; U; Linux 2.2.15 i686)" \
    -d "sub=Confirma&opcao=lattes&cpf=${id}&senha=${password}" \
    -k -e "www.cnpq.br" \
    -c /tmp/cookie.txt \
    -o /tmp/login.html \
    "https://wwws.cnpq.br/sigef_imp/owa/pservicos.entrada"

you can even try it with some bogus values:

id=100
password=foo

it will not give you an password or id error. the downloaded page has an
error (in portuguese) saying that or the user is trying to access this
page without accessing the main page (www.cnpq.br) first, or the cookies
support is disabled. in fact, this code it is not generating a
cookie.txt file, not even if I do:

curl -c cookie.txt www.cnpq.br

but if I access this page with firefox and live http headers, it shows
that a cookie is indeed used:

------------------------------------------------------------------------
Host: www.cnpq.br
[snip]
Cookie: imp=cnpqrestritos; imp2=|||||||||¦¦|¦|¦||||||||||¦||¦|¦¦|||||||||¦||¦¦¦||||||||||¦||||||||||||||||¦||||¦||||||||||¦¦||¦||||||||||¦|||¦¦¦||||||||||¦¦||¦||||||||||¦¦|¦|¦||||||||||¦||¦¦||; cvclwsess=
Pragma: no-cache
Cache-Control: no-cache
------------------------------------------------------------------------

To sumarise, in order to access this page I have to save cookies and
access the main page first. I tried using the -e flag, or accessing the
main page first with curl. But I believe that the problem here is that a
cookie file is not generated. I've tried with -b and -L as well.

Any ideas?

Pedro Kroger
Received on 2007-02-28