Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Z
zzsn_spider
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
王景浩
zzsn_spider
Commits
6a49a9de
提交
6a49a9de
authored
12月 18, 2023
作者:
薛凌堃
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
经营分析脚本维护
上级
b127603f
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
38 行增加
和
15 行删除
+38
-15
经营分析.py
comData/caiwushuju/经营分析.py
+38
-15
没有找到文件。
comData/caiwushuju/经营分析.py
浏览文件 @
6a49a9de
impor
t
pymysql
impor
t
pymysql
...
@@ -8,6 +8,8 @@ import time
...
@@ -8,6 +8,8 @@ import time
import
numpy
as
np
import
numpy
as
np
import
json
import
json
import
datetime
import
datetime
import
sys
sys
.
path
.
append
(
'D:
\\
KK
\\
zzsn_spider
\\
base'
)
import
BaseCore
import
BaseCore
baseCore
=
BaseCore
.
BaseCore
()
baseCore
=
BaseCore
.
BaseCore
()
log
=
baseCore
.
getLogger
()
log
=
baseCore
.
getLogger
()
...
@@ -63,7 +65,7 @@ def operate_analysis(i,com_code,social_code):
...
@@ -63,7 +65,7 @@ def operate_analysis(i,com_code,social_code):
list_category
.
append
(
'按产品分类'
)
list_category
.
append
(
'按产品分类'
)
if
one_info
[
'MAINOP_TYPE'
]
==
'3'
:
if
one_info
[
'MAINOP_TYPE'
]
==
'3'
:
list_category
.
append
(
'按地区分类'
)
list_category
.
append
(
'按地区分类'
)
select_sql
=
f
'''select stock_code from operation_analysis
_copy1
where stock_code =
%
s and date = '{one_info['REPORT_DATE'][:10]}' '''
select_sql
=
f
'''select stock_code from operation_analysis where stock_code =
%
s and date = '{one_info['REPORT_DATE'][:10]}' '''
y
=
cursor
.
execute
(
select_sql
,
com_code
[
2
:])
y
=
cursor
.
execute
(
select_sql
,
com_code
[
2
:])
if
y
:
if
y
:
i
+=
1
i
+=
1
...
@@ -157,34 +159,55 @@ def operate_analysis(i,com_code,social_code):
...
@@ -157,34 +159,55 @@ def operate_analysis(i,com_code,social_code):
print
(
f
'{com_code}'
,
response
.
text
)
print
(
f
'{com_code}'
,
response
.
text
)
except
Exception
as
e
:
except
Exception
as
e
:
print
(
e
)
print
(
e
)
log
.
info
(
f
'数据疑似有重复===={com_code}'
)
send_end
=
time
.
time
()
send_end
=
time
.
time
()
log
.
info
(
f
'{com_code} 传入接口用时:{send_end-send_start}'
)
log
.
info
(
f
'{com_code} 传入接口用时:{send_end-send_start}'
)
return
com_code
,
list_code
,
list_zygc
,
list_income
,
list_income_sca
,
list_chengben
,
list_chengben_sca
,
list_lirun
,
list_lirun_sca
,
list_maolilv
,
list_time
,
list_category
return
com_code
,
list_code
,
list_zygc
,
list_income
,
list_income_sca
,
list_chengben
,
list_chengben_sca
,
list_lirun
,
list_lirun_sca
,
list_maolilv
,
list_time
,
list_category
else
:
else
:
return
return
df_all
=
pd
.
read_excel
(
'D:/kkwork/zzsn_spider/data/上市企业(有财务数据)清单.xlsx'
,
dtype
=
str
)
#
df_all = pd.read_excel('D:/kkwork/zzsn_spider/data/上市企业(有财务数据)清单.xlsx',dtype=str)
list_non
=
[]
list_non
=
[]
i
=
1
i
=
1
while
True
:
while
True
:
if
i
>=
len
(
df_all
):
# 从redis中获取企业信用代码
log
.
info
(
'采集已完成'
)
social_code
=
baseCore
.
redicPullData
(
'Jingyingfenxi:finance_socialCode'
)
break
# if i>=len(df_all):
start_time
=
time
.
time
()
# log.info('采集已完成')
com_code_
=
df_all
[
'股票代码'
][
i
]
# break
social_code
=
df_all
[
'信用代码'
][
i
]
# start_time = time.time()
num
=
len
(
com_code_
)
# com_code_ = df_all['股票代码'][i]
if
'HK'
in
com_code_
:
# social_code = df_all['信用代码'][i]
# num = len(com_code_)
if
social_code
==
None
or
social_code
==
'None'
:
log
.
info
(
'======已没有数据==========等待====='
)
time
.
sleep
(
20
)
if
baseCore
.
check_mysql_conn
(
cnx
):
cnx
=
baseCore
.
cnx_
cursor
=
baseCore
.
cursor_
sql_sel
=
f
'''select securities_code,exchange from sys_base_enterprise_ipo where exchange = '1' or exchange = '2' or exchange = '3' and listed = '1' and social_credit_code='{social_code}' '''
cursor
.
execute
(
sql_sel
)
row
=
cursor
.
fetchone
()
try
:
securities_code
=
row
[
0
]
pass
except
:
log
.
info
(
f
'======{social_code}没有股票代码======'
)
continue
exchange
=
row
[
1
]
num
=
len
(
securities_code
)
if
'HK'
in
securities_code
:
# com_code = com_code_.split('.')[0]
# com_code = com_code_.split('.')[0]
i
+=
1
i
+=
1
continue
continue
else
:
else
:
if
num
!=
6
:
if
num
!=
6
:
com_code1
=
'0'
*
(
6
-
num
)
+
com_code_
com_code1
=
'0'
*
(
6
-
num
)
+
securities_code
else
:
else
:
com_code1
=
com_code_
com_code1
=
securities_code
# 股票代码0、2、3开头的为深圳交易所,6、9开头的为上海交易所,8开头的为北京交易所
# 股票代码0、2、3开头的为深圳交易所,6、9开头的为上海交易所,8开头的为北京交易所
if
com_code1
[
0
]
==
'2'
or
com_code1
[
0
]
==
'0'
or
com_code1
[
0
]
==
'3'
:
if
com_code1
[
0
]
==
'2'
or
com_code1
[
0
]
==
'0'
or
com_code1
[
0
]
==
'3'
:
com_code
=
'sz'
+
com_code1
com_code
=
'sz'
+
com_code1
...
@@ -193,7 +216,7 @@ while True:
...
@@ -193,7 +216,7 @@ while True:
elif
com_code1
[
0
]
==
'8'
or
com_code1
[
0
]
==
'4'
:
elif
com_code1
[
0
]
==
'8'
or
com_code1
[
0
]
==
'4'
:
com_code
=
'bj'
+
com_code1
com_code
=
'bj'
+
com_code1
else
:
else
:
log
.
error
(
f
'{
com_code_
},{social_code}:无法获取正确的股票代码!'
)
log
.
error
(
f
'{
securities_code
},{social_code}:无法获取正确的股票代码!'
)
list_updata
=
[]
list_updata
=
[]
# # 判断该条信息是否已经采集过
# # 判断该条信息是否已经采集过
# select_sql = '''select stock_code from operation_analysis_copy1 where stock_code = %s'''
# select_sql = '''select stock_code from operation_analysis_copy1 where stock_code = %s'''
...
@@ -310,6 +333,6 @@ while True:
...
@@ -310,6 +333,6 @@ while True:
# end_time = time.time()
# end_time = time.time()
# log.info(f'企业经营分析采集用时:{end_time-start_time}')
# log.info(f'企业经营分析采集用时:{end_time-start_time}')
break
#
break
# df_non = pd.DataFrame(list_non)
# df_non = pd.DataFrame(list_non)
# df_non.to_excel('无经营分析数据企业.xlsx',index=False)
# df_non.to_excel('无经营分析数据企业.xlsx',index=False)
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论