def __init__(self, basepath): self.recinfo = Recinfo(basepath) self.position = ExtractPosition(self.recinfo) self.epochs = behavior_epochs(self.recinfo) self.artifact = findartifact(self.recinfo) self.makePrmPrb = makePrmPrb(self.recinfo) self.utils = SessionUtil(self.recinfo) self.spikes = spikes(self.recinfo) self.brainstates = SleepScore(self.recinfo) self.swa = Hswa(self.recinfo) self.theta = Theta(self.recinfo) self.spindle = Spindle(self.recinfo) self.gamma = Gamma(self.recinfo) self.ripple = Ripple(self.recinfo) self.placefield = pf(self.recinfo) self.replay = Replay(self.recinfo) self.decode = DecodeBehav(self.recinfo) self.localsleep = LocalSleep(self.recinfo) self.viewdata = SessView(self.recinfo) self.pbe = PBE(self.recinfo) self.eventpsth = event_event()
from sessionUtil import SessionUtil from logUtil import LogUtil from dictUtil import DictUtil import traceback import json def handleData(returnStr): jsonData=json.loads(returnStr) dateList=jsonData.get('date') dataList=jsonData.get('data1') return dateList,dataList def storeData(dateStr,dataStr,conn,cur,wdzjPlatId): sql='insert into platIncomeRate (date,incomeRate,wdzjPlatId) values ("'+dateStr+'","'+dataStr+'","'+wdzjPlatId+'")' cur.execute(sql) conn.commit() conn,cur=DatabaseUtil().getConn() session=SessionUtil() logUtil=LogUtil("platIncomeRate.log") cur.execute('select wdzjPlatId from platData where month="2017-06"') data=cur.fetchall() print(data) mylist=list() print(data) for i in range(0,len(data)): platId=str(data[i].get('wdzjPlatId')) mylist.append(platId) print mylist for i in mylist: url='http://shuju.wdzj.com/plat-info-target.html' try:
def storeData(jsonOne, conn, cur, planId): amount = jsonOne.get('amount') createTime = jsonOne.get('createTime') finalAmout = jsonOne.get('finalAmout') nickName = jsonOne.get('nickName') tradeMethod = jsonOne.get('tradeMethod') ucodeId = jsonOne.get('ucodeId') userId = jsonOne.get('userId') sql = 'insert into RRDXinPlanInvest (amount,createTime,finalAmout,nickName,tradeMethod,ucodeId,userId,planId) values ("' + amount + '","' + createTime + '","' + finalAmout + '","' + nickName + '","' + tradeMethod + '","' + ucodeId + '","' + userId + '","' + planId + '")' cur.execute(sql) conn.commit() conn, cur = DatabaseUtil().getConn() session = SessionUtil() logUtil = LogUtil("xinPlanInvest.log") cur.execute('select planId from RRDXinPlanList order by planId') data = cur.fetchall() for i in range(0, len(data)): planId = str(data[i].get('planId')) url = 'https://www.renrendai.com/autoinvestplan/listPlan!getAutoInvestPlanBuyerRecords.action?autoInvestPlanId=' + planId + '&_=' + str( int(time.time())) logUtil.warning(planId) try: data = session.getReq(url) investList = handleData(data) if len(investList) > 0: for j in range(len(investList)): dictObject = DictUtil(investList[j]) storeData(dictObject, conn, cur, planId)
import sys import traceback from databaseUtil import DatabaseUtil from sessionUtil import SessionUtil from htmlUtil import HtmlUtil from logUtil import LogUtil from dictUtil import DictUtil import json reload(sys) sys.setdefaultencoding('utf8') def storeData(htmlObject,conn,cur,logUtil,loanId): creditinfo=htmlObject.find('script',{'id':'credit-info-data'}).text jsonData=json.loads(creditinfo) jsonOne=jsonData.get('data') loanInfo=jsonOne.get('loan') beginBidTime=loanInfo.get('beginBidTime') sql='update RRDZhaiquanDetail set beginBidTime="'+beginBidTime+'" where loanId="'+loanId+'"' cur.execute(sql) conn.commit() logUtil.warning(loanId) session=SessionUtil() conn,cur=DatabaseUtil().getConn() logUtil=LogUtil("zhaiquanUpdate.log") for i in range(2029567,2209630): url="https://www.renrendai.com/loan/"+str(i) try: htmlObject=HtmlUtil(session.getReq(url)) storeData(htmlObject,conn,cur,logUtil,str(i)) except Exception,e: logUtil.warning(traceback.print_exc())
planList=jsonData.get('data').get('plans') return planList def storeData(jsonOne,conn,cur,logUtil,loanId): amount=jsonOne.get('amount') earnInterest=jsonOne.get('earnInterest') expectedYearRate=jsonOne.get('expectedYearRate') fundsuserRate=jsonOne.get('fundsUseRate') planId=jsonOne.get('id') name=jsonOne.get('name') status=jsonOne.get('status') subpointCountActual=jsonOne.get('subpointCountActual') sql='insert into RRDXinPlanList (amount,earnInterest,expectedYearRate,fundsUseRate,planId,name,status,subpointCountActual) values ("'+amount+'","'+earnInterest+'","'+expectedYearRate+'","'+fundsuserRate+'","'+planId+'","'+name+'","'+status+'","'+subpointCountActual+'")' print(sql) logUtil.warning(loanId) cur.execute(sql) conn.commit() session=SessionUtil() conn,cur=DatabaseUtil().getConn() logUtil=LogUtil("uplanList.log") for i in range(1,73): url='https://www.renrendai.com/autoinvestplan/listPlan!listPlanJson.action?pageIndex='+str(i)+'&_='+str(int(time.time())) try: planList=handleData(session.getReq(url)) for j in range(len(planList)): dictObject=DictUtil(planList[j]) storeData(dictObject,conn,cur,logUtil,str(i)) except Exception,e: logUtil.warning(traceback.print_exc()) cur.close() conn.close()