Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
credit-report-api
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
QA
credit-report-api
Commits
9acec8d0
Commit
9acec8d0
authored
Aug 26, 2019
by
张鹏程
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增“”表头信息"
parent
b8307955
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
67 additions
and
4 deletions
+67
-4
ReportAnalysis_Handler.py
handler/ReportAnalysis_Handler.py
+8
-4
Head_Service.py
service/Head_Service.py
+53
-0
InitHtml_Service.py
service/InitHtml_Service.py
+5
-0
PersonalInformation_Service.py
service/PersonalInformation_Service.py
+1
-0
征信报告.ipynb
testfile/征信报告.ipynb
+0
-0
No files found.
handler/ReportAnalysis_Handler.py
View file @
9acec8d0
...
...
@@ -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
:
...
...
service/Head_Service.py
0 → 100644
View file @
9acec8d0
# -*- 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
service/InitHtml_Service.py
View file @
9acec8d0
...
...
@@ -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
]
...
...
service/PersonalInformation_Service.py
View file @
9acec8d0
...
...
@@ -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
():
...
...
testfile/征信报告.ipynb
View file @
9acec8d0
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment