connect to website providing login & pwd

-:fs fs at
Sun Sep 30 06:38:59 CEST 2001


i'm rather new to python and try to connect to a webpage
this works fine (i get the html-text) when the page is not secured

when it is a secure page, which requires a login and a password, how can i
provide these ???

i  use the code from httplib like this

V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V

import httplib
import sys
import getopt
import string

opts, args = getopt.getopt(sys.argv[1:], 'd')
dl = 0
for o, a in opts:
    if o == '-d': dl = dl + 1

host = ''
selector = '/test/manage/'            >>>>>>>>>>> trying to call the manage
window of a ZOPE server

if args[0:]: host = args[0]
if args[1:]: selector = args[1]

h = httplib.HTTP()


h.putrequest('GET', selector)

h.putheader("login", "test")       >>>>>>>>>>>>> ??????????????? doesn't
h.putheader("password", "test")  >>>>>>>>>>>> ??????????????? work

status, reason, headers = h.getreply()
print 'status =', status
print 'reason =', reason
if headers:
    for header in headers.headers: print string.strip(header)

print h.getfile().read()

V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V

thanks for any help

steindl friedrich

More information about the Python-list mailing list