Perhaps try mechanize? http://wwwsearch.sourceforge.net/mechanize/
On Sat, Mar 15, 2008 at 12:57 PM, SwartMumba snake <[EMAIL PROTECTED]> wrote: > 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). > > --- On Sat, 3/15/08, Kent Johnson <[EMAIL PROTECTED]> wrote: > > From: Kent Johnson <[EMAIL PROTECTED]> > Subject: Re: [Tutor] login > To: [EMAIL PROTECTED] > Cc: [email protected] > Date: Saturday, March 15, 2008, 11:44 AM > > SwartMumba snake wrote: > > I am trying to get the cookies from the site when I login, though > > html.info(). The problem is that when I check the source ( html.read() > ) > > it shows that it does not recognize me as logged in. Also, if I chech > > html.info(), the cookies that I am suppose to receive, if I logged in > > successfully, are not there. What am I doing wrong? > > urllib2 does not support cookies by default, you have to configure it > with a CookieJar: > > import cookielib, urllib2 > > cj = cookielib.CookieJar() > opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) > > Then use this opener as below. I think you will have to look at the > CookieJar to see the cookies. > > Kent > > > opener.addheaders = [('User-Agent', 'Mozilla/5.0 (Windows; U; > Windows NT > > 6.0; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12'), > > ('Referer', > 'http://www.site.org/index.php') > > ] > > > > values = urllib.urlencode({'user_name': 'MyUsername', > 'user_pass': > > 'MyPass^^', 'login' : 'Login'}) > > req = urllib2.Request('http://www.site.org/index.php', values) > > > > html = opener.open(req) > ________________________________ > Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it > now. > _______________________________________________ > Tutor maillist - [email protected] > http://mail.python.org/mailman/listinfo/tutor > > -- Michael Langford Phone: 404-386-0495 Consulting: http://www.RowdyLabs.com _______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
