I have no problem pulling pages using httplib if the pages do not require authentication. But now I want to pull pages only after authenticating. Access is enforced by the contributed auth package.
import httplib, urllib params = urllib.urlencode({'this_is_the_login_form':1,'username': 'myuser', 'password': 'test'}) headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"} conn = httplib.HTTPConnection("myserver") conn.request("POST", "/login/", params, headers) response = conn.getresponse() print response.status, response.reason As I said, when hitting pages that do not require auth, I am successful and get a 200 response code. But when auth is needed, I get 302 for the code and "found" for the status. Any insights? On Feb 17, 12:28 pm, Antoni Aloy <antoni.a...@gmail.com> wrote: > 2009/2/17 Miguel <migue...@gmail.com>:> thanks karen, that is what I meant. > > >>> importhttplib, urllib > >>> params = urllib.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0}) > >>> headers = {"Content-type": "application/x-www-form-urlencoded", > > ... "Accept": "text/plain"} > > >>> conn =httplib.HTTPConnection("musi-cal.mojam.com:80") > >>> conn.request("POST", "/cgi-bin/query", params, headers) > >>> response = conn.getresponse() > >>> print response.status, response.reason > 200 OK > >>> data = response.read() > >>> conn.close() > > Hope it helps! > > -- > Antoni Aloy López > Blog:http://trespams.com > Site:http://apsl.net --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---