curl-and-python

Re: cookies rejected

From: Manu J <manu.1982_at_gmail.com>
Date: Sat, 18 Sep 2004 18:28:17 +0530

Hi,

The problem gets more mysterious. :-)

Set cookie fields from the page that says cookie rejected
-------------------------------------------------------------------------------------------------------

Set-Cookie: F=a=8CMN7DAsvWUJU9.DDZlkfKsi5syrj2rDod98UIJieQsl9NWkYKIDPSXbhaED&b=dRXZ;
expires=Thu, 15 Apr 2010 20:00:00 GMT; path=/; domain=.yahoo.com
Set-Cookie: Y=v=1&n=b0sejb2igi994&l=1ekd3b4ii3h40cp/o&p=m2gvvin113000500&jb=24|69|&iz=60036&r=a3&lg=uk&intl=in&np=1;
path=/; domain=.yahoo.com
Set-Cookie: T=z=/HzSBB/NITBBLZa9vWB5tviTzMGNDE3NTQxMk4zMg--&a=QAE&sk=DAAe90W/B62O/z&d=c2wBT0RRQk16WXdNak0yTlRrME5RLS0BYQFRQUUBdGlwAUxmYzFDQwF6egEvSHpTQkJnV0E-;
path=/; domain=.yahoo.com
Set-Cookie: I=ir=dd&in=3d024c7&i1=DDABiK; expires=Fri, 08 Oct 2004
18:50:39 GMT; path=/; domain=.yahoo.com

------------------------------------------------------------------------------------------------
entries in cookie-file generated by curl

.yahoo.com TRUE / FALSE 1271361600 F
a=8CMN7DAsvWUJU9.DDZlkfKsi5syrj2rDod98UIJieQsl9NWkYKIDPSXbhaED&b=dRXZ
.yahoo.com TRUE / FALSE 0 Y
v=1&n=b0sejb2igi994&l=1ekd3b4ii3h40cp/o&p=m2gvvin113000500&jb=24|69|&iz=60036&r=a3&lg=uk&intl=in&np=1
.yahoo.com TRUE / FALSE 0 T
z=/HzSBB/NITBBLZa9vWB5tviTzMGNDE3NTQxMk4zMg--&a=QAE&sk=DAAe90W/B62O/z&d=c2wBT0RRQk16WXdNak0yTlRrME5RLS0BYQFRQUUBdGlwAUxmYzFDQwF6egEvSHpTQkJnV0E-
.yahoo.com TRUE / FALSE 1097261439 I
ir=dd&in=3d024c7&i1=DDABiK

-----------------------------------------------------------------------------------------------------------------------------------

so the cookies are getting stored.

now from the command line when i use this command

 curl -b yahoo_cookie.txt -c yahoo_cookie.txt -x http://10.7.0.1:9090
-L http://mail.yahoo.com -v | grep unread

it correctly retrieves my yahoo mail page after a couple of
redirections. !he cookie_file is the same as above

now when try to do the same thing using pycurl it doesn't work !
the following is my python code

----------------------------------------------------
cookie_file = '/home/manu/prog/python/yahoo_cookie.txt'

while 1:
        url="http://mail.yahoo.com"
        html3 = Test()
        c = pycurl.Curl()
        c.setopt(c.URL,url )
        c.setopt(c.USERAGENT, "User-Agent: Mozilla/5.0 (X11; U; Linux; en-US)
Gecko/2004 Firefox/0.9")
        c.setopt(c.FOLLOWLOCATION,1);
        c.setopt(c.HEADER,1);
        c.setopt(c.MAXREDIRS,5);
        c.setopt(c.COOKIEJAR,cookie_file);
        c.setopt(c.COOKIEFILE,cookie_file);
        c.setopt(c.PROXY,"http://10.7.0.1:9090")
        c.setopt(c.WRITEFUNCTION, html3.body_callback)
        c.perform()
        c.close()

        file = open("yahoo3.html","w")
        file.write(html3.contents)
        file.close
        time.sleep(20)

-----------------------------------------------------------------------------------
the file yahoo3.html contains yahoo login page.

am i doing something wrong here?

since curl works perfectly from command line i guess it's a pycurl issue or
i screwed up ;-)

Thanks in advance
Regards
Manu
_______________________________________________
http://cool.haxx.se/mailman/listinfo/curl-and-python
Received on 2004-09-18