Commit 6c0c7f14 authored by 张鹏程's avatar 张鹏程

修改bug

1. 贷记卡部分未解析出来
2. 贷记卡列表缺少最后一条数据
parent 15e99060
......@@ -27,30 +27,47 @@ class TransactionDetails(Base):
if '贷款' in tag.keys():
result.update(self.get_Loan_Details(tag['贷款']))
if '贷记卡' in tag.keys():
result.update(self.get_DebitCard_Details(tag['贷记卡']))
result.update(self.get_DebitCard_Details(tag['贷记卡'],'贷记卡'))
if '准贷记卡' in tag.keys():
result.update(self.get_DebitCard_Details(tag['准贷记卡']))
result.update(self.get_DebitCard_Details(tag['准贷记卡'],'准贷记卡'))
return result
def get_menuDetailsList(self,tag):
# def get_menuDetailsList(self,tag):
# """交易信息明细小标题拆分"""
# _result = []
# _temp = []
# for i in tag:
# if i.td.attrs:
# try :
# if i.div['align'] == 'left':
# # print(list( re.findall('([0-9]\d{0,2})[\.]{1}(\S+)',i.div.get_text())[0]))
# _temp.extend(list( re.findall('([0-9]\d{0,2})[\.]{1}(\S+)',i.div.get_text())[0]))
# elif i.div['align'] == 'center':
# _temp.append(i)
# except:
# _temp.append(None)
# else:
# if i.table:
# _temp.append(i) #
# if _temp:
# _result.append(_temp)
# _temp = []
# return _result
def get_menuDetailsList(self,tag): # 交易信息明细拆分
"""交易信息明细小标题拆分"""
_result = []
_temp = []
for i in tag:
if i.td.attrs:
try :
if i.div['align'] == 'left':
# print(list( re.findall('([0-9]\d{0,2})[\.]{1}(\S+)',i.div.get_text())[0]))
_temp.extend(list( re.findall('([0-9]\d{0,2})[\.]{1}(\S+)',i.div.get_text())[0]))
elif i.div['align'] == 'center':
_temp.append(i)
except:
for i,v in enumerate(tag):
if v.td.get('align'):
# print(i,v)
table = v.next_sibling.next_sibling
_temp.extend(list(re.findall('([0-9]\d{0,2})[\.]{1}(\S+)',v.div.get_text())[0]))
if table.div:
_temp.append(table)
else:
_temp.append(None)
else:
if i.table:
_temp.append(i) #
if _temp:
_result.append(_temp)
_result.append(_temp)
_temp = []
return _result
......@@ -144,14 +161,17 @@ class TransactionDetails(Base):
table_json['近5年逾期记录'] = table_json.pop('逾期记录')
if '账户状态' in table_json.keys() and table_json['账户状态'] != '' and table_json['账户状态'] != None:
if '账户状态' in _json.keys():
del _json['账户状态']
_json.update(table_json)
_result.append(_json)
result['贷款'] = _result
return result
def get_DebitCard_Details(self,tag):
def get_DebitCard_Details(self,tag,key):
"""贷记卡明细拆分"""
result = {'贷记卡':{}}
result = {key:{}}
_result = []
for v in tag:
_json = {}
......@@ -201,13 +221,13 @@ class TransactionDetails(Base):
table_json['逾期记录'] = df.to_dict(orient='records')
table_json['近5年逾期记录'] = table_json.pop('逾期记录')
if '账户状态' in table_json.keys() and table_json['账户状态'] == '正常':
if '账户状态' in table_json.keys() and table_json['账户状态'] != '' and table_json['账户状态'] != None:
if '账户状态' in _json.keys():
del _json['账户状态']
_json.update(table_json)
_result.append(_json)
result['贷记卡'] = _result
result[key] = _result
return result
def get_json_DebitCard(self,tag):
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment