示例#1
0
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())
示例#2
0
    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)
    except Exception, e:
        logUtil.warning(traceback.print_exc())
cur.close()
conn.close
示例#3
0
    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()