<table cellspacing='0' cellpadding='0' border='0' ><tr><td style='font: inherit;'>Using the cookie jar is not going to solve my problem. I don't want to use the cookie jar. I just want to send the right request so that I will be sent back the right header, which will contain the information that I want. Apparently I am not sending the right request because the header that I am receieving does not have the "Set-Cookie"s that I want. i.e. I am being recognized as not logged in (non member etc).<br><br>--- On Sat, 3/15/08, Kent Johnson <kent37@tds.net> wrote:<br><br> From: Kent Johnson <kent37@tds.net><br> Subject: Re: [Tutor] login<br> To: swartmumba@yahoo.com<br> Cc: Tutor@python.org<br> Date: Saturday, March 15, 2008, 11:44 AM<br><br> SwartMumba snake wrote:<br> > I am trying to get the cookies from the site when I
login, though <br> > html.info(). The problem is that when I check the source ( html.read() ) <br> > it shows that it does not recognize me as logged in. Also, if I chech <br> > html.info(), the cookies that I am suppose to receive, if I logged in <br> > successfully, are not there. What am I doing wrong?<br><br> urllib2 does not support cookies by default, you have to configure it <br> with a CookieJar:<br><br> import cookielib, urllib2<br><br> cj = cookielib.CookieJar()<br> opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))<br><br> Then use this opener as below. I think you will have to look at the <br> CookieJar to see the cookies.<br><br> Kent<br><br> > opener.addheaders = [('User-Agent',
'Mozilla/5.0 (Windows; U;<br> Windows NT <br> > 6.0; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12'),<br> > ('Referer',<br> 'http://www.site.org/index.php')<br> > ]<br> > <br> > values = urllib.urlencode({'user_name': 'MyUsername',<br> 'user_pass': <br> > 'MyPass^^', 'login' : 'Login'})<br> > req = urllib2.Request('http://www.site.org/index.php', values)<br> > <br> > html = opener.open(req)</td></tr></table><br>
<hr size=1>Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. <a href="http://us.rd.yahoo.com/evt=51733/*http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ "> Try it now.</a>