<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 &lt;kent37@tds.net&gt; wrote:<br><br>&nbsp;&nbsp;&nbsp; From: Kent Johnson &lt;kent37@tds.net&gt;<br>&nbsp;&nbsp;&nbsp; Subject: Re: [Tutor] login<br>&nbsp;&nbsp;&nbsp; To: swartmumba@yahoo.com<br>&nbsp;&nbsp;&nbsp; Cc: Tutor@python.org<br>&nbsp;&nbsp;&nbsp; Date: Saturday, March 15, 2008, 11:44 AM<br><br>&nbsp;&nbsp;&nbsp; SwartMumba snake wrote:<br>&nbsp;&nbsp;&nbsp; &gt; I am trying to get the cookies from the site when I
 login, though <br>&nbsp;&nbsp;&nbsp; &gt; html.info(). The problem is that when I check the source ( html.read() ) <br>&nbsp;&nbsp;&nbsp; &gt; it shows that it does not recognize me as logged in. Also, if I chech <br>&nbsp;&nbsp;&nbsp; &gt; html.info(), the cookies that I am suppose to receive, if I logged in <br>&nbsp;&nbsp;&nbsp; &gt; successfully, are not there. What am I doing wrong?<br><br>&nbsp;&nbsp;&nbsp; urllib2 does not support cookies by default, you have to configure it <br>&nbsp;&nbsp;&nbsp; with a CookieJar:<br><br>&nbsp;&nbsp;&nbsp; import cookielib, urllib2<br><br>&nbsp;&nbsp;&nbsp; cj = cookielib.CookieJar()<br>&nbsp;&nbsp;&nbsp; opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))<br><br>&nbsp;&nbsp;&nbsp; Then use this opener as below. I think you will have to look at the <br>&nbsp;&nbsp;&nbsp; CookieJar to see the cookies.<br><br>&nbsp;&nbsp;&nbsp; Kent<br><br>&nbsp;&nbsp;&nbsp; &gt; opener.addheaders = [('User-Agent',
 'Mozilla/5.0 (Windows; U;<br>&nbsp;&nbsp;&nbsp; Windows NT <br>&nbsp;&nbsp;&nbsp; &gt; 6.0; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12'),<br>&nbsp;&nbsp;&nbsp; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ('Referer',<br>&nbsp;&nbsp;&nbsp; 'http://www.site.org/index.php')<br>&nbsp;&nbsp;&nbsp; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ]<br>&nbsp;&nbsp;&nbsp; &gt; <br>&nbsp;&nbsp;&nbsp; &gt; values = urllib.urlencode({'user_name': 'MyUsername',<br>&nbsp;&nbsp;&nbsp; 'user_pass': <br>&nbsp;&nbsp;&nbsp; &gt; 'MyPass^^', 'login' : 'Login'})<br>&nbsp;&nbsp;&nbsp; &gt; req = urllib2.Request('http://www.site.org/index.php', values)<br>&nbsp;&nbsp;&nbsp; &gt; <br>&nbsp;&nbsp;&nbsp; &gt; 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>