Commit 9acec8d0 authored by 张鹏程's avatar 张鹏程

新增“”表头信息"

parent b8307955
......@@ -5,6 +5,7 @@ from utils import JsonUtil
from handler.Base_Handler import BaseHandler
import json
from config import settings
from service.Head_Service import Heads # 调查信息和被调查者的相关信息
from service.PersonalInformation_Service import PersonalInformation # 个人基本信息
from service.InformationSummary_Service import InformationSummary # 信息概要
from service.TransactionDetails_Service import TransactionDetails # 信贷交易明细
......@@ -36,27 +37,30 @@ class ReportAnalysis(BaseHandler):
if isFile:
try :
import datetime
html = InitHtml(htmlhandle)
asslysis = ['PersonalInformation',
'InformationSummary',
'TransactionDetails',
'QueryInfomation'
]
# maxconnections = 1 #最大并发数
# maxconnections = len(asslysis) #最大并发数
# semlock = threading.BoundedSemaphore(maxconnections)
# t = []
# for i in range(maxconnections):
# semlock.acquire()
# t.append(threading.Thread(target=eval(asslysis[i]),args=(html.menu_dict,)))
# semlock.release()
#
# t.append(threading.Thread(target=eval(asslysis[i]),args=(html.menu_dict,semlock)))
#
# t[i].start()
Heads(html.heads)
PersonalInformation(html.menu_dict)
InformationSummary(html.menu_dict)
TransactionDetails(html.menu_dict)
QueryInfomation(html.menu_dict)
result = Result.get_result()
Result.clear_result()
# '/Users/zhangpengcheng/Documents/量化派代码管理/credit-report-api/html/data.json'
if self._isdownload:
with open(settings.TO_JSON+'/'+self._filepath.split('/')[-1]+'.json', 'w',encoding='utf8') as file_obj:
......
# -*- coding:utf-8 -*-
import json
from collections import defaultdict
import bs4
import pandas as pd
from service.Base_Service import Base,Result
class Heads(Base):
"""表头信息 1. 调查信息 2. 被调用户信息"""
def __init__(self,html):
Base.__init__(self,html)
Result.set_result({'表头':self.get_Logic(self.menu_dict)})
pass
def get_Logic(self,tag):
result = {}
result.update(self.get_heads_report(tag[0]))
result.update(self.get_heads_user(tag[1]))
return result
def get_heads_report(self,tag):
"""报告信息"""
result = {}
tds = tag.table.find_all('td')
for ii, i in enumerate(tds):
if isinstance(i,bs4.element.Tag):
if i.get('class') != None and 'high' in i.get('class'):
tm = ''
for msg in i.stripped_strings:
tm+=msg
tm = tm.split(':')
result.update({tm[0]:tm[1]})
return result
def get_heads_user(self,tag):
"""用户信息"""
result = {}
table = self.get_table(tag)
result.update(self.get_json(table))
return result
def get_information_Identity(self,tag,name):
"""身份信息"""
result = {name:{}}
tag_msg = tag[name][0].tbody.children
msg = self.get_json(tag_msg)
for k,v in msg.items():
for i in v:
result[name].update(i)
result.update(result)
return result
\ No newline at end of file
......@@ -17,6 +17,8 @@ class InitHtml:
# detail = self.children[2].tbody.find_all('tr')
# menu_detail = detail[4:]
menu_detail = children[2].tbody.children
self.heads = []
self.heads.append(children[1]) # 表头 - 调查信息
self.menu_dict = self.get_menu(menu_detail) # 获取报告标题信息
def get_children(self,soup):
......@@ -52,6 +54,9 @@ class InitHtml:
key = None
for ii ,i in enumerate(menu):
if isinstance(i,bs4.element.Tag):
if ii == 1:
# 取得被调查的信息
self.heads.append(i)
con = i.contents
if con :
menu = con[1]
......
......@@ -17,6 +17,7 @@ class PersonalInformation(Base):
Result.set_result(self.get_Logic(self.menu_personalInformation))
else:
Result.set_result({'个人基本信息':None})
def get_Logic(self,tag):
result = {}
if '身份信息' in tag.keys():
......
This diff is collapsed.
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