Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mancheng
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
mancheng
Commits
0d47e3e4
Commit
0d47e3e4
authored
Dec 26, 2022
by
dong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix20221226
parent
a0d4f441
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
5 deletions
+44
-5
apps/view_index/view.py
+44
-5
No files found.
apps/view_index/view.py
View file @
0d47e3e4
...
...
@@ -2,11 +2,13 @@ import json
import
os
import
sys
import
requests
from
aliyunsdkcore.client
import
AcsClient
from
aliyunsdkcore.acs_exception.exceptions
import
ClientException
from
aliyunsdkcore.acs_exception.exceptions
import
ServerException
from
aliyunsdkvod.request.v20170321.GetPlayInfoRequest
import
GetPlayInfoRequest
from
flask
import
request
,
jsonify
,
session
,
current_app
from
lxml
import
etree
from
sqlalchemy
import
func
,
desc
,
or_
from
apps.models
import
*
from
apps.view_index
import
api_attract
...
...
@@ -18,6 +20,48 @@ from apps import db, constants, redis_store
from
apps.util
import
verify_token
# 数据通报
@api_attract.route
(
"/DataNotification"
,
methods
=
[
"GET"
])
def
data_notification
():
page_html_list
=
[
"index.shtml"
,
# 首页
"index_1.shtml"
,
# 第2页
"index_2.shtml"
,
# 第3页
"index_3.shtml"
,
# 第4页
"index_4.shtml"
,
# 第5页
"index_5.shtml"
,
# 第6页
"index_6.shtml"
,
# 第7页
]
data_list1
=
[]
for
page_index
in
page_html_list
:
url
=
"http://zsj.jcgov.gov.cn/sjtb/sjtb/{}"
.
format
(
page_index
)
headers
=
{
'User-Agent'
:
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36 Edg/108.0.1462.54'
}
try
:
respose
=
requests
.
get
(
url
,
headers
=
headers
)
respose
.
encoding
=
'utf-8'
if
respose
.
status_code
==
200
:
html_etree
=
etree
.
HTML
(
respose
.
text
)
# handeled_html_str = etree.tostring(html_etree).decode()
# print(handeled_html_str)
data_list
=
[]
content_name_list
=
html_etree
.
xpath
(
'//div[@class="newslist newslistdixx"]//span[@class="list_newstitle"]/a/text()'
)
content_url_list
=
html_etree
.
xpath
(
'//div[@class="newslist newslistdixx"]//span[@class="list_newstitle"]/a/@href'
)
i
=
0
for
content_name
in
content_name_list
:
data_dic
=
{
"content_name"
:
content_name
,
"content_url"
:
content_url_list
[
i
]
.
replace
(
'./'
,
'http://zsj.jcgov.gov.cn/sjtb/sjtb/'
)}
data_list
.
append
(
data_dic
)
i
+=
1
data_list1
=
data_list
+
data_list1
continue
return
jsonify
(
code
=
RET
.
OK
,
msg
=
"获取成功"
,
data
=
data_list1
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
jsonify
(
code
=
RET
.
DBERR
,
msg
=
"数据库错误"
)
def
get_jjzb
(
district
,
year
):
'''经济指标数据'''
year1
=
datetime
.
now
()
.
year
-
1
...
...
@@ -67,11 +111,6 @@ def get_jjzb(district, year):
return
jsonify
(
code
=
RET
.
DBERR
,
msg
=
"数据库错误"
)
@api_attract.route
(
"/view_index"
,
methods
=
[
"GET"
])
def
index
():
return
'德旭,你好!'
# 左上角企业数量各资质统计、左上角获取经济指标数据、产业机构分布饼状图数据统计
@api_attract.route
(
"/menu"
,
methods
=
[
"POST"
])
def
menu
():
...
...
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