def __init__(self, **kwargs): if "_id" in kwargs: self._id = kwargs.pop("_id") else: self._id = kwargs.pop("id", None) import util util.json_parse(self, kwargs)
def _get_checkin_token(self): token_url = 'http://115.com/?ct=event&ac=get_active_param&_=%d' % ( time.time() * 1000) resp = self._url_opener.open(token_url) result = util.json_parse(resp.read()) token = result['is_take_token'] if result['state'] else '' return token
def pick_spaces(self): token = self._get_take_token() picked_size = 0 if len(token.strip()) > 0: pick_url = 'http://115.com/?ct=ajax_user&ac=pick_spaces&u=1&token=%s' % token resp = self._url_opener.open(pick_url) result = util.json_parse(resp.read()) picked_size = result['picked_num'] if result['state'] else 0 return picked_size
def checkin(self): token = self._get_checkin_token() if len(token.strip()) > 0: checkin_url = 'http://115.com/?ct=ajax_user&ac=checkin' resp = self._url_opener.open(checkin_url, urllib.urlencode({'token' : token})) result = util.json_parse(resp.read()) return result['state'] else: return False
def checkin(self): token = self._get_checkin_token() if len(token.strip()) > 0: checkin_url = 'http://115.com/?ct=ajax_user&ac=checkin' resp = self._url_opener.open(checkin_url, urllib.urlencode({'token': token})) result = util.json_parse(resp.read()) return result['state'] else: return False
def _login(self, account, password): vcode = _create_uniqid() query = { 'login[safe]' : 1, 'login[safe_login]' : 0, 'login[ssoent]' : 'A1', 'login[ssoext]' : vcode, 'login[ssoln]' : account, 'login[ssopw]' : _sha1_password(account, password, vcode), 'login[ssovcode]' : vcode, 'login[time]' : 1, 'login[version]' : '2.0', 'goto' : 'http://115.com/' } # 执行登陆请求 login_url = 'http://passport.115.com/?ct=login&ac=ajax&is_ssl=1' resp = self._url_opener.open(login_url, urllib.urlencode(query)) result = util.json_parse(resp.read()) if result['state'] == False: raise LoginException()
def _login(self, account, password): vcode = _create_uniqid() query = { 'login[safe]': 1, 'login[safe_login]': 0, 'login[ssoent]': 'A1', 'login[ssoext]': vcode, 'login[ssoln]': account, 'login[ssopw]': _sha1_password(account, password, vcode), 'login[ssovcode]': vcode, 'login[time]': 1, 'login[version]': '2.0', 'goto': 'http://115.com/' } # 执行登陆请求 login_url = 'http://passport.115.com/?ct=login&ac=ajax&is_ssl=1' resp = self._url_opener.open(login_url, urllib.urlencode(query)) result = util.json_parse(resp.read()) if result['state'] == False: raise LoginException()
def _get_checkin_token(self): token_url = 'http://115.com/?ct=event&ac=get_active_param&_=%d' % (time.time() * 1000) resp = self._url_opener.open(token_url) result = util.json_parse(resp.read()) token = result['is_take_token'] if result['state'] else '' return token
def __init__(self, **kwargs) -> None: import util util.json_parse(self, kwargs)
def __setstate__(self, d): import util util.json_parse(self, d)