On Oct 23, 12:55 am, Ralf Schönian <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] schrieb: > > > > > > > Trying to figure out how to add login verfication. I believe it is > > logging me in, but theres no way to really tell..any ideas? or > > tutorials out there that can exaplain this to me? > > > Thanks > > > import urllib,urllib2,cookielib > > > passlst = open(passfile, 'r').readlines() > > url="http://somesite" > > cj = cookielib.LWPCookieJar() > > opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) > > urllib2.install_opener(opener) > > TheForm = urllib.urlencode({"username":"myid","password":"mypas"}) > > request = urllib2.Request(url, TheForm) > > result = urllib2.urlopen(request) > > html=result.read() > > result.close() > > I had the same trouble. There was a redirect after login a had to > follow. Look at the following code. > > def login(self): > ''' Log into web site. ''' > > self._br.set_handle_redirect(True) > cj = CookieJar() > self._br.set_cookiejar(cj) > self._br.open(Config.urlLogin) > self._br.select_form(name='login') > > self._br['session_key'] = Config.username > self._br['session_password'] = Config.password > response=self._br.submit() > self._br.set_response(response) > for link in self._br.links(url_regex="www.somesite.com"): > self._br.follow_link(link) > if 'Sign In' in self._br.title(): > raise ValueError('Wrong password') > > Regards, > Ralf Schoenian- Hide quoted text - > > - Show quoted text -
Thank you very much, ill look into it..
-- http://mail.python.org/mailman/listinfo/python-list