def login(self, username='', passwd='', app_user_nick=None, target=None, use_taobaoid=False): if use_taobaoid: systime = SysTime() params = { 'app_key' : self.API_KEY, 'timestamp' : systime.get(), 'sign_method' : self.SIGN_METHOD, } if app_user_nick!=None: params['app_user_nick'] = app_user_nick if target!=None: params['target'] = target src = self.APP_SECRET + ''.join(["%s%s" % (k, v) for k, v in sorted(params.iteritems())]) + self.APP_SECRET params['sign'] = md5(src).hexdigest().upper() form_data = urllib.urlencode(params) rsp = requests.get('%s?%s'%(self.TaobaoID_URL, form_data)) print rsp.content else: rsp = requests.get('%s%s'%(self.LOGIN_URL, self.API_KEY)) soup = BeautifulSoup(rsp.content) iframe_src = soup.find('iframe')['src'] rsp = requests.get(iframe_src) print rsp.url #s = requests.session() login_url = 'https://login.taobao.com/member/login.jhtml' soup = BeautifulSoup(rsp.content) login_url = soup.find('form')['action'] #inputs = soup.findAll('input') forms = self.extract_form_fields(soup) forms['TPL_username'] = username forms['TPL_password'] = passwd rsp = requests.post(login_url, data=forms) print rsp.url print rsp.content
def logout(self): systime = SysTime() params = { 'app_key' : self.API_KEY, 'timestamp' : systime.get(), 'sign_method' : self.SIGN_METHOD, } src = self.APP_SECRET + ''.join(["%s%s" % (k, v) for k, v in sorted(params.iteritems())]) + self.APP_SECRET params['sign'] = md5(src).hexdigest().upper() form_data = urllib.urlencode(params) rsp = requests.get('%s?%s'%(self.LOGOUT_URL, form_data)) if 'login.taobao.com' in rsp.url: return True return False
def logout(self): systime = SysTime() params = { 'app_key': self.API_KEY, 'timestamp': systime.get(), 'sign_method': self.SIGN_METHOD, } src = self.APP_SECRET + ''.join( ["%s%s" % (k, v) for k, v in sorted(params.iteritems())]) + self.APP_SECRET params['sign'] = md5(src).hexdigest().upper() form_data = urllib.urlencode(params) rsp = requests.get('%s?%s' % (self.LOGOUT_URL, form_data)) if 'login.taobao.com' in rsp.url: return True return False
def login(self, username='', passwd='', app_user_nick=None, target=None, use_taobaoid=False): if use_taobaoid: systime = SysTime() params = { 'app_key': self.API_KEY, 'timestamp': systime.get(), 'sign_method': self.SIGN_METHOD, } if app_user_nick != None: params['app_user_nick'] = app_user_nick if target != None: params['target'] = target src = self.APP_SECRET + ''.join( ["%s%s" % (k, v) for k, v in sorted(params.iteritems())]) + self.APP_SECRET params['sign'] = md5(src).hexdigest().upper() form_data = urllib.urlencode(params) rsp = requests.get('%s?%s' % (self.TaobaoID_URL, form_data)) print rsp.content else: rsp = requests.get('%s%s' % (self.LOGIN_URL, self.API_KEY)) soup = BeautifulSoup(rsp.content) iframe_src = soup.find('iframe')['src'] rsp = requests.get(iframe_src) print rsp.url #s = requests.session() login_url = 'https://login.taobao.com/member/login.jhtml' soup = BeautifulSoup(rsp.content) login_url = soup.find('form')['action'] #inputs = soup.findAll('input') forms = self.extract_form_fields(soup) forms['TPL_username'] = username forms['TPL_password'] = passwd rsp = requests.post(login_url, data=forms) print rsp.url print rsp.content