On Tuesday, December 13, 2011 2:09:31 PM UTC-5, peter wrote:
>
> def test():
>         import urllib
>         url="http://127.0.0.1:8000/admin/default/site";
>         f = urllib.urlopen(url)
>         s = f.read()
>         return s
>
> I have to login again even though I am logged in on my computer. So
> the question is, can I somehow add the 'context' to s so that it
> recognises that I am already logged in?
>
> I am using web2py's admin as an example, but the solution should work
> for any website.
>
Are you saying you want to programmatically login to a website and then 
retrieve a particular page that requires a login on that site? Look into 
urllib2: http://docs.python.org/howto/urllib2.html. I think it's pretty 
easy if the site supports basic authentication, otherwise a little more 
complex (requires posting form data and managing cookies).

Anthony
 

Reply via email to