def getUserRecord(): """ 获得用户信息 :return: """ params = {'_': getTimestamp(), 'menuid': '000100030001'} url = 'http://iservice.10010.com/e3/static/query/searchPerInfo/' self.headers[ 'Referer'] = 'http://iservice.10010.com/e3/query/personal_xx.html' options = { 'method': 'post', 'url': url, 'params': params, 'cookies': self.cookies, 'headers': self.headers } response = Request.basic(options) if response: item = dict() result = json.loads(response.text)['result'] try: item['user_valid'] = 1 if result[ 'usercirclestatus'] == u'有效期' else 0 except KeyError: item['user_valid'] = 1 for k, v in result['MyDetail'].items(): if k in Table.KEY_CONVERT_USER.keys(): columm_name = Table.KEY_CONVERT_USER[k] item[columm_name] = v del self.phone_attr['password'] self.user_items.append(dict(item, **self.phone_attr)) else: return dict(code=4000, func='clawCallRecords')
def clawPageCall(date_tuple, page_no=1, resend=2): #完成单次请求[存在网络繁忙则重传] """完成单次请求""" params = {'_': '1468549625712', 'menuid': '000100030001'} form = { 'pageNo': '1', 'pageSize': '20', 'beginDate': '2016-07-01', 'endDate': '2016-07-18' } form['pageNo'] = page_no form['beginDate'] = date_tuple[0] form['endDate'] = date_tuple[1] params['_'] = getTimestamp() url = 'http://iservice.10010.com/e3/static/query/callDetail' self.headers['Referer'] = 'http://iservice.10010.com/' \ 'e3/query/call_dan.html?menuId=000100030001' options = { 'method': 'post', 'url': url, 'form': form, 'params': params, 'cookies': self.cookies, 'headers': self.headers } response = Request.basic(options) if response: try: page_json = json.loads(response.text) except ValueError: # return False return returnResult(4100, [], desc='clawPageCall1') else: if 'errorMessage' in page_json.keys( ) and resend > 0: # 存在系统繁忙 try: if page_json['errorMessage'][ 'respCode'] == '4114030193': return clawPageCall(date_tuple, page_no, resend - 1) # 繁忙重传 except KeyError: # return False return returnResult(4100, [], desc='clawPageCall2') else: return response.text else: # return False return returnResult(4000, [], desc='clawPageCall')
def coroutineClawPageCall(date_tuple, page_no=1, resend=2): #完成单次请求[存在网络繁忙则重传] """完成单次请求""" params = {'_': getTimestamp(), 'menuid': '000100030001'} form = { 'pageNo': page_no, 'pageSize': '20', 'beginDate': date_tuple[0], 'endDate': date_tuple[1] } url = 'http://iservice.10010.com/e3/static/query/callDetail' self.headers[ 'Referer'] = 'http://iservice.10010.com/e3/query/call_dan.html?menuId=000100030001' options = { 'method': 'post', 'url': url, 'form': form, 'params': params, 'cookies': self.cookies, 'headers': self.headers } response = Request.basic(options) if response: try: page_json = json.loads(response.text) except ValueError: pass else: if 'errorMessage' in page_json.keys( ) and resend > 0: # 存在系统繁忙 try: if page_json['errorMessage'][ 'respCode'] == '4114030193': return clawPageCall(date_tuple, page_no, resend - 1) # 繁忙重传 except KeyError: pass else: text_seq.append(response.text) print '注意:协助完成处理{0}日到{1}日记录中的第{2}页'.format( date_tuple[0], date_tuple[1], page_no) else: pass
def sysCheckLoginAgain(): """ 检查是否登录 :return: getHeaderView() """ url = 'http://iservice.10010.com/e3/static/check/checklogin/?_=' + getTimestamp( ) self.headers[ 'Referer'] = 'http://iservice.10010.com/e3/query/call_dan.html?menuId=000100030001' options = { 'method': 'post', 'url': url, 'cookies': self.cookies, 'headers': self.headers } response = Request.basic(options) if response: return getHeaderView() else: return dict(code=4000, func='sysCheckLoginAgain')
def loginByJS(): """ 通过get登录,更新cookies :return: judgeLogin(response)/dict() """ params = { '_': '1468474921490', # req_time + 1 'callback': 'jQuery172000024585669494775475_1468770450339', 'password': '******', 'productType': '01', 'pwdType': '01', 'redirectType': '03', 'redirectURL': 'http://www.10010.com', 'rememberMe': '1', 'req_time': '1468474921489', 'userName': '******' } params['req_time'] = getTimestamp() params['_'] = str(int(params['req_time']) + 1) params['userName'] = self.phone_attr['phone'] params['password'] = self.phone_attr['password'] url = 'https://uac.10010.com/portal/Service/MallLogin' self.headers['Referer'] = 'http://uac.10010.com/portal/hallLogin' options = { 'method': 'get', 'url': url, 'params': params, 'cookies': None, 'headers': self.headers } response = Request.basic(options) if response: return judgeLogin(response) else: return dict(code=4000, data=[], desc='loginByJS', func='loginByJS')
def sysCheckLogin(): """ 登录检查,更新cookies :return: loginByJS()/dict """ url = 'http://iservice.10010.com/e3/static/check/checklogin/?_=' + getTimestamp( ) self.headers[ 'Referer'] = 'http://iservice.10010.com/e3/query/call_dan.html?menuId=000100030001' options = { 'method': 'post', 'url': url, 'cookies': None, 'headers': self.headers } response = Request.basic(options) if response: self.cookies.update(dict_from_cookiejar(response.cookies)) return loginByJS() else: return dict(code=4000, data=[], desc='sysCheckLogin', func='sysCheckLogin')