随机森林预测财务报表是否舞弊

爬取财务报表

“”"
e.g: http://data.eastmoney.com/bbsj/201806/lrb.html
“”"
import requests
import re
from multiprocessing import Pool
import json
import csv
import pandas as pd
import os
import time

设置文件保存在c盘eastmoney文件夹下

file_path = ‘C:\eastmoney’
if not os.path.exists(file_path):
os.mkdir(file_path)
os.chdir(file_path)

1 设置表格爬取时期

def set_table():
print(’*’ * 80)
print(’\t\t\t\t东方财富网报表下载’)
print(‘作者:高级农民工 2018.10.10’)
print(’--------------’)

# 1 设置财务报表获取时期
year = int(float(input('请输入要查询的年份(四位数2016-2019):\n')))
# int表示取整,里面加float是因为输入的是str,直接int会报错,float则不会
# https://stackoverflow.com/questions/1841565/valueerror-invalid-literal-for-int-with-base-10
while (year < 2016 or year > 2019):
    year = int(float(input('年份数值输入错误,请重新输入:\n')))

quarter = int(float(input('请输入小写数字季度(1:1季报,2-年中报,3:3季报,4-年报):\n')))
while (quarter < 1 or quarter > 4):
    quarter = int(float(input('季度数值输入错误,请重新输入:\n')))

# 转换为所需的quarter 两种方法,2表示两位数,0表示不满2位用0补充,
# http://www.runoob.com/python/att-string-format.html
quarter = '{:02d}'.format(quarter * 3)
# quarter = '%02d' %(int(month)*3)

# 确定季度所对应的最后一天是30还是31号
if (quarter == '06') or (quarter == '09'):
    day = 30
else:
    day = 31
date = '{}-{}-{}' .format(year, quarter, day)
# print('date:', date)  # 测试日期 ok

# 2 设置财务报表种类
tables = int(
    input('请输入查询的报表种类对应的数字(1-业绩报表;2-业绩快报表:3-业绩预告表;4-预约披露时间表;5-资产负债表;6-利润表;7-现金流量表): \n'))

dict_tables = {1: '业绩报表', 2: '业绩快报表', 3: '业绩预告表',
               4: '预约披露时间表', 5: '资产负债表', 6: '利润表', 7: '现金流量表'}

dict = {1: 'YJBB', 2: 'YJKB', 3: 'YJYG',
        4: 'YYPL', 5: 'ZCFZB', 6: 'LRB', 7: 'XJLLB'}
category = dict[tables]

# js请求参数里的type,第1-4个表的前缀是'YJBB20_',后3个表是'CWBB_'
# 设置se
  • 3
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值