I’m trying to download a file with curl. To do these, first I must be logged in to be able to download the file. I’m trying with curl but it doesn’t work. I saw the HTTP Headers and I don’t understand why doesn’t it work. Any help is appreciated.
The commands that I use are:
curl -A 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.4) Gecko/20091030 Gentoo Firefox/3.5.4' --referer http://www.sportstracklive.com/signin -d 'userCredentialsForm.userCredentials.email=USERNAME%40gmail.com&userCredentialsForm.userCredentials.password=PASSWROD&_target1=Login' https://www.sportstracklive.com/signin -c cook.txt -v > pepelu
curl -A 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.4) Gecko/20091030 Gentoo Firefox/3.5.4' --referer http://www.sportstracklive.com/signin -b cook.txt -v http://www.sportstracklive.com/user/username > pepelu2
This is working fine for me.
If you want any other page after you log in, you have to use
-b trackcookie.txt:You always need the
-Loption to log on to pages with cookie based authentication, because a cookie needs to be sent as part of the headers before any html, so it needs to redirect. The exception is cookies written by javascript, but that’s another chapter.EDIT: You’re right. I wasn’t logged in after all. The correct way to log in is:
The cookie actually lives on after you log out, so it seems like it’s this sequence of server requests that determines whether the session id in the cookie corresponds to a valid session or not. I figured that out after I got to download the zip file with curl using the same session id set in Firefox when I was logged in there, but only then.