Skip to content

Commit

Permalink
update renrendai
Browse files Browse the repository at this point in the history
  • Loading branch information
Nyloner committed Oct 3, 2018
1 parent 9316eee commit d1cf09b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
13 changes: 10 additions & 3 deletions www.renrendai.com/lender_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ def get_lender_records(loan_id):
loan_id)
req = build_request(url)
data = req.json()
keys = ['loanId', 'userId', 'userNickName',
'financeCategory', 'amount', 'lendTime']
keys = ['loanId', 'id', 'lenderType', 'userId', 'userNickName',
'financeCategory', 'orderNo', 'bussNo', 'amount', 'lendTime']
if 'status' in data and data['status'] == 0:
result = []
base_info = [data['data']['joinCount'], data['data']['amount']]
base_info = []
for lender in data['data']['list']:
lender_line = []
for key in keys:
Expand All @@ -68,9 +68,16 @@ def get_lender_records(loan_id):


def append_to_csv_file(lines, filename):
add_header = False
if not os.path.exists(filename):
add_header = True
csvfile = codecs.open(filename, 'a', encoding='utf-8')
spamwriter = csv.writer(csvfile, delimiter=',',
quotechar='"', quoting=csv.QUOTE_ALL)
if add_header:
header = ['loanId', 'id', 'lenderType', 'userId', 'userNickName',
'financeCategory', 'orderNo', 'bussNo', 'amount', 'lendTime']
spamwriter.writerow(header)
for line in lines:
spamwriter.writerow(line)
csvfile.close()
Expand Down
26 changes: 17 additions & 9 deletions www.renrendai.com/renrendai.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# 密码
j_password = ''

Cookies = {}
Cookies = {'we_sid': 's%3AVnsu1YeXpmWPmQ5tk_Xjs9j3nSQHPwrO.arDCn31SVQ6dPdEmAqGPbl%2B%2F9lKXEzS0WlTyEt7E3GA'}

headers = {
'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:39.0) Gecko/20100101 Firefox/39.0',
Expand All @@ -27,15 +27,17 @@
'Connection': 'keep-alive'}


info_keys = ['officeScale', 'carLoan', 'realName', 'creditLevel', 'office', 'province', 'officeType', 'idNo', 'sumCreditPoint', 'houseLoan', 'marriage', 'userId', 'city', 'position',
'university', 'workYears', 'birthDay', 'graduation', 'homeTown', 'carYear', 'hasHouse', 'gender', 'hasCar', 'officeDomain', 'availableCredits', 'promotion', 'nickName', 'salary', 'carBrand']
loan_keys = ['loanId', 'title', 'amount', 'status', 'interest', 'repayType', 'verifyState', 'borrowerLevel',
'borrowType', 'months', 'leftMonths', 'description', 'openTime', 'startTime', 'readyTime', 'passTime', 'nickName', 'address', 'jobType']
detail_keys = ['totalCount', 'successCount', 'alreadyPayCount',
'borrowAmount', 'notPayTotalAmount', 'overdueAmount', 'overdueCount']
credit_keys = ['identificationScanning', 'mobile', 'graduation', 'credit', 'residence', 'marriage', 'child', 'album', 'work', 'renren', 'kaixin', 'house',
'car', 'identification', 'detailInformation', 'borrowStudy', 'mobileReceipt', 'incomeDuty', 'other', 'account', 'titles', 'fieldAudit', 'mobileAuth', 'video']


def parser_loan(item):
info_keys = ['officeScale', 'carLoan', 'realName', 'creditLevel', 'office', 'province', 'officeType', 'idNo', 'sumCreditPoint', 'houseLoan', 'marriage', 'userId', 'city', 'position',
'university', 'workYears', 'birthDay', 'graduation', 'homeTown', 'carYear', 'hasHouse', 'gender', 'hasCar', 'officeDomain', 'availableCredits', 'promotion', 'nickName', 'salary', 'carBrand']
loan_keys = ['loanId', 'title', 'amount', 'status', 'interest', 'repayType', 'verifyState', 'borrowerLevel',
'borrowType', 'months', 'leftMonths', 'description', 'startTime', 'passTime', 'nickName', 'address', 'jobType']
detail_keys = ['totalCount', 'successCount', 'alreadyPayCount',
'borrowAmount', 'notPayTotalAmount', 'overdueAmount', 'overdueCount']
credit_keys = ['identification', 'borrowStudy',
'incomeDuty', 'credit', 'identificationScanning', 'work']
info = []
for key in loan_keys:
try:
Expand Down Expand Up @@ -68,9 +70,15 @@ def parser_loan(item):


def append_to_csv_file(lines, filename):
add_header = False
if not os.path.exists(filename):
add_header = True
csvfile = codecs.open(filename, 'a', encoding='utf-8')
spamwriter = csv.writer(csvfile, delimiter=',',
quotechar='"', quoting=csv.QUOTE_ALL)
if add_header:
header = loan_keys+info_keys+detail_keys+credit_keys
spamwriter.writerow(header)
for line in lines:
spamwriter.writerow(line)
csvfile.close()
Expand Down

0 comments on commit d1cf09b

Please sign in to comment.