def login(self, sender, psw): if not sender or not psw: return '' app = MSNPost(sender, psw) if app.login(): return app.web.cookies_to_str() else: return ''
def addfriend(self, sender, psw, to, cookie): if not sender or not psw: return '' app = MSNPost(sender, psw) app.web.make_req('https://profile.live.com') app.web.set_cookies(cookie) try: if app.add_friend(to): logging.info('%s add %s success', sender, to) return 'success' else: logging.error('%s add %s fail', sender, to) return 'fail' except Exception, info: logging.info('%s add %s get exception %s', sender, to, info.__class__.__name__) return info.__class__.__name__