cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: trying to get/generate cookies

From: Ray Satiro via curl-users <curl-users_at_cool.haxx.se>
Date: Fri, 6 May 2016 02:14:09 -0400

On 5/5/2016 6:22 PM, bruce wrote:
> Targeting a given site. I do two (2) curls in the hopes of generating
> cookies with the 1st curl, that would then drive the 2nd curl.
>
> However, I can't seem to generate cookies at all.
>
> On a clean FF, Ie, delete cookies, using Firebug, I can use the 1st
> url, which generates cookies, and can then use the 2nd url to get the
> page..
>
> Any pointers on what's wrong????
>
> Thanks
>
> running centos 6.5
>
> echo "" > aa.lwp
> curl -vvv -A 'Mozilla/5.0 (X11; Linux x86_64; rv:38.0)
> Gecko/20100101 Firefox/38.0' -H 'Host: www.bkstr.com
> <http://www.bkstr.com>' -H -H 'Accept:
> text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' -H
> 'Accept-Language: en-US,en;q=0.5' -H 'Connection: keep-alive'
> --cookie-jar aa.lwp --cookie aa.lwp -L
> 'http://www.bkstr.com/missouristatestore/home'
>
> curl -vvv -A 'Mozilla/5.0 (X11; Linux x86_64; rv:38.0)
> Gecko/20100101 Firefox/38.0' -H 'Host: www.bkstr.com
> <http://www.bkstr.com>' -H -H 'Accept:
> text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' -H
> 'Accept-Language: en-US,en;q=0.5' -H 'Connection: keep-alive'
> --cookie-jar aa.lwp --cookie aa.lwp -L
> 'http://www.bkstr.com/webapp/wcs/stores/servlet/CourseMaterialsResultsView?catalogId=10001&categoryId=9604&storeId=10875&langId=-1&programId=529&termId=21601&divisionDisplayName=%20&departmentDisplayName=ACC&courseDisplayName=109&sectionDisplayName=701&demoKey=d&purpose=browse'

It looks like you'll need at least a JSESSIONID which on that site seems
to be set by javascript only.

curl --silent -b "JSESSIONID=" -A "Mozilla/5.0 (X11; Linux x86_64;
rv:38.0) Gecko/20100101 Firefox/38.0" -L
"http://www.bkstr.com/webapp/wcs/stores/servlet/CourseMaterialsResultsView?catalogId=10001&categoryId=9604&storeId=10875&langId=-1&programId=529&termId=21601&divisionDisplayName=%20&departmentDisplayName=ACC&courseDisplayName=109&sectionDisplayName=701&demoKey=d&purpose=browse"|
grep DtmObject.product

You'll notice if you grep JSESSIONID you can see some of the cookies
that would be set by javascript. You would extract the JSESSIONID,
otherwise it will just generate a new one every time you connect. Though
I think in this case working with a javascript engine would be easier,
the caching code is very obfuscated and if you don't get the F5 and Tea
cookies right you could end up with some delays.

-------------------------------------------------------------------
List admin: https://cool.haxx.se/list/listinfo/curl-users
FAQ: https://curl.haxx.se/docs/faq.html
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2016-05-06