def login(self): login_page = self.web.get_page(self.APP_URL) url = self.get_auto_refresh_url(login_page) if url and url.find('cid-') != -1: self.log.debug('found cid %s', url) return True if url: login_page = self.web.get_page(url) post_url = text.get_in(login_page, "urlPost:'", "'") #log.debug('get post_url %s, url %s', post_url, self.web.url) if not post_url: return False data = html.get_hidden(login_page) data.update({'login' : self.name, 'passwd' : self.psw, 'NewUser' : '1', }) #self.log.debug('get post data %s', data) #req = urllib2.Request(url, data=data, headers=headers) result = self.web.get_page(post_url, data=data, headers={'referer' : self.web.url}) if result is None: self.log.debug('post %s is_name', post_url) return False if result.find('onload="javascript:DoSubmit();"') != -1: result = self.web.submit(result) #ret = self.proof(result) #if ret: # raise ProofException() if self.web.url.find('Logincredprof.aspx') != -1: #self.log.debug('into active account') result = self.active(result) if result is None: self.log.debug('active account fail') return False if self.web.url.find('Logincredprof.aspx') == -1: self.log.trace("active success") return True self.log.trace("active fail got url %s", self.web.url) return True
def active(self, login_page): posturl = text.get_in(login_page, '<form method="post" action="', '"') posturl = 'https://account.live.com/' + posturl.replace('&', '&') data = html.get_hidden(login_page) data.update({ '__EVENTTARGET' : '', 'ctl00$ctl00$MainContent$MainContent$AccountContent$LoginMain$iPwdEncrypted' : 'afvTFRcnT7hEK2A1CQg9lYHtxmOSKF9o7cbm1pVUmL0vGiWz7FPKuZTTOHyf6hLFdG8y7sflCefQiCgU5IefiI6unwC+B6502BweGR8+7HE+Zu3Mm8UAECa4ZJ5ij/Mr0zzetzuq1E4sKqzy4IXbZLnAaomAI4J4ti3yvq1hlJA=', 'ctl00$ctl00$MainContent$MainContent$AccountContent$LoginMain$iPublicKey' : '1BEF90811CE78A99D0820E87F3BDF1F96622EB40', 'ctl00$ctl00$MainContent$MainContent$AccountContent$LoginWrapper$LoginRepeater$ctl00$LoginOther$iEncryptedSecretAnswer' : 'ZWmr8HXra02k0yizc09c5BES6p8RgW7evH3LmtZE9GJRibebShlE2ABH95b8/zva0dXY0v32XhvnsWolTZqfXPKwcoC1ONTadeBTWlLnqlzgU78P4OT2jjWx2rHhwrbVlvkYPP3J9QomBbf8uigVI/739HTw+Fvx8TbkoNWZGFA=', 'ctl00$ctl00$MainContent$MainContent$AccountContent$LoginWrapper$LoginRepeater$ctl00$LoginOther$iQuestion' : '母亲的出生地点', 'ctl00$ctl00$MainContent$MainContent$AccountContent$btSubmit' : '接受', }) data.pop('ctl00$ctl00$MainContent$MainContent$AccountContent$iErrors') page = self.web.get_page(posturl, data, {'Origin': 'https://account.live.com'}) return page
def login(self): login_page = self.web.get_page(self.APP_URL) post_url = text.get_in(login_page, "urlPost:'", "'") log.debug('get post_url %s, url %s', post_url, self.web.url) if not post_url: return False data = html.get_hidden(login_page) data.update({'login' : self.name, 'passwd' : self.psw, 'NewUser' : '1', }) self.log.debug('get post data %s', data) #req = urllib2.Request(url, data=data, headers=headers) result = self.web.get_page(post_url, data=data, headers={'referer' : self.web.url}) if result is None: self.log.debug('post %s is_name', post_url) return False if result.find('onload="javascript:DoSubmit();"') != -1: result = self.web.submit(result) if self.web.url.find('Logincredprof.aspx') != -1: self.log.debug('into active account') result = self.active(result) if result is None: self.log.debug('active account fail') if self.web.url.find('/Proofs/Manage') != -1: proofs_page = self.web.submit(result) result = self.proofs(proofs_page) if result is None: raise ProofException() if result.find('javascript:rd();') != -1: return True return False