当前位置: 首页 > news >正文

英文企业网站源码成都住建官网app

英文企业网站源码,成都住建官网app,dedecms 网站名称标签,建设展示类网站的意义基于不依赖wind、某花顺等第三方平台数据的考虑,尝试直接从财报中解析三大报表进而计算ROE等财务指标,因此需要下载沪深两市的上市公司财报数据,便于后续从pdf中解析三大报表。 深市爬虫好做,先放深市爬虫: 根据时间段…

基于不依赖wind、某花顺等第三方平台数据的考虑,尝试直接从财报中解析三大报表进而计算ROE等财务指标,因此需要下载沪深两市的上市公司财报数据,便于后续从pdf中解析三大报表。
深市爬虫好做,先放深市爬虫:

'''
根据时间段下载深交所上市公司财报
path str 指定财报存储路径
time str 财报年度 如[2023,2024]
stock_list list 下载财报的股票代码列表 例如['000001','000002']
financial_statements_type list 财报的类别 例如['annual','semi-annual','quarterly_1','quarterly_3'] 分别为年报、半年报、一季报、三季报
'''
def get_financial_statements(path, time, stock_list, financial_statements_type):url = "https://www.szse.cn/api/disc/announcement/annList"headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3','Content-Type': 'application/json','Connection': 'close'}download_url = "https://disc.static.szse.cn/download"# 逐只股票读取相应pdf报表for stock in stock_list:# 逐年循环for year in time:# 根据财报类型逐个读取pdffor fs_type in financial_statements_type:if fs_type == 'annual':title = "年报"bigCategoryId = '010301'   # 年报查询代码timestart = str(year)+"-12-31"timeend = str(year+1)+"-09-01"  # 防止出现财报更正之后时间节点覆盖不到,统一往后推三个月elif fs_type == 'semi-annual':title = "中报"bigCategoryId = '010303'   # 中报查询代码timestart = str(year) + "-07-01"timeend = str(year) + "-12-31"elif fs_type == 'quarterly_1':title = "一季报"bigCategoryId = '010305'   # 一季报查询代码timestart = str(year) + "-04-01"timeend = str(year) + "-07-31"else:title = "三季报"bigCategoryId = '010307'   # 三季报查询代码timestart = str(year) + "-10-01"timeend = str(year) + "-12-31"data = {"seDate": [timestart, timeend],"stock": [stock],"channelCode": ["listedNotice_disc"],"bigCategoryId": [bigCategoryId],"pageSize": 50,"pageNum": 1}response = requests.post(url=url, data=json.dumps(data), headers=headers)data = json.loads(response.text)["data"]if len(data) == 0 or data is None:print("警告:股票代码:"+stock+" "+str(year)+title+"不存在!")else:for entry in data:# 对摘要栏目做特殊处理if entry['title'].find("报告摘要") < 0:# 检查path路径下stock代码文件夹、年份文件夹是否存在,不存在则创建file_path = path+stock+"/"+str(year)if Tools.check_folder_exists(path+stock) == False:os.mkdir(path+stock)if Tools.check_folder_exists(file_path) == False:os.mkdir(file_path)file = file_path + "/" + str(year) + title + "##" + entry['title'].replace("*", "") + ".pdf"# 检查文件是否已存在,不存在再下载if os.path.exists(file):print("警告:股票代码:" + stock + " " + str(year) + title + "已存在!")else:filecontent = requests.get(download_url + entry["attachPath"])with open(file, "wb") as pdf:pdf.write(filecontent.content)print("股票代码:" + stock + " " + str(year) + title + "写入成功。")# 爬虫调用实例:
# timestart = [2023,2024]
# stock_list = ['000001','000002']
# financial_statements_type = ['annual', 'semi-annual', 'quarterly_1', 'quarterly_3']
# SZ_financial_statement_path = "F:/data/SZ/"
# get_financial_statements(SZ_financial_statement_path, timestart,stock_list,financial_statements_type)

沪市爬虫:

'''
根据时间段下载上交所上市公司财报
time str 财报年度 如2024、2023
stock_list list 下载财报的股票代码列表 例如['000001','000002']
financial_statements_type list 财报的类别 例如['annual','semi-annual','quarterly_1','quarterly_3'] 分别为年报、半年报、一季报、三季报
'''
def get_financial_statements(path, time, stock_list, financial_statements_type):headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3','Referer': 'https://www.sse.com.cn/','Connection': 'close'}download_url = "https://www.sse.com.cn"# 逐只股票读取相应pdf报表for stock in stock_list:# 逐年循环for year in time:# 根据财报类型逐个读取pdffor fs_type in financial_statements_type:if fs_type == 'annual':title = "年报"bigCategoryId = 'YEARLY'  # 年报查询代码timestart = str(year) + "-12-31"timeend = str(year + 1) + "-09-01"  # 防止出现财报更正之后时间节点覆盖不到,统一往后推三个月elif fs_type == 'semi-annual':title = "中报"bigCategoryId = 'QUATER2'  # 中报查询代码timestart = str(year) + "-07-01"timeend = str(year) + "-12-31"elif fs_type == 'quarterly_1':title = "一季报"bigCategoryId = 'QUATER1'  # 一季报查询代码timestart = str(year) + "-04-01"timeend = str(year) + "-07-31"else:title = "三季报"bigCategoryId = 'QUATER3'  # 三季报查询代码timestart = str(year) + "-10-01"timeend = str(year) + "-12-31"url = "https://query.sse.com.cn/security/stock/queryCompanyBulletin.do?jsonCallBack=jsonpCallback"+str(random.randint(10000, 999999))+"&isPagination=true&pageHelp.pageSize=50&pageHelp.pageNo=1&pageHelp.beginPage=1&pageHelp.cacheSize=1&pageHelp.endPage=1&productId="+stock+"&securityType=0101%2C120100%2C020100%2C020200%2C120200&reportType2=DQBG&reportType="+bigCategoryId+"&beginDate="+timestart+"&endDate="+timeendresponse = requests.get(url=url, headers=headers)datas = json.loads(response.text.split('"keyWord":null,"pageHelp":')[1].split(',"productId":')[0])['data']if len(datas) == 0 or datas is None:print("警告:股票代码:" + stock + " " + str(year) + title + "不存在!")else:for entry in datas:# 对摘要栏目做特殊处理,去除摘要if entry['TITLE'].find("摘要") < 0:# 检查path路径下stock代码文件夹、年份文件夹是否存在,不存在则创建file_path = path + stock + "/" + str(year)if Tools.check_folder_exists(path + stock) == False:os.mkdir(path + stock)if Tools.check_folder_exists(file_path) == False:os.mkdir(file_path)file = file_path + "/" + str(year) + title + "##" + entry['TITLE'].replace("*", "") + ".pdf"# 检查文件是否已存在,不存在再下载if os.path.exists(file):print("警告:股票代码:" + stock + " " + str(year) + title + "已存在!")else:filecontent = requests.get(download_url + entry["URL"])with open(file, "wb") as pdf:pdf.write(filecontent.content)print("股票代码:" + stock + " " + str(year) + title + "写入成功。")
# timestart = [2023]
# stock_list = ['600011']
# financial_statements_type = ['annual', 'semi-annual', 'quarterly_1', 'quarterly_3']
# SZ_financial_statement_path = "F:/data/SH/"
# get_financial_statements(SZ_financial_statement_path, timestart,stock_list,financial_statements_type)
http://www.yayakq.cn/news/702197/

相关文章:

  • 做全网营销型网站建设北京网站开发网站建设价格
  • 用新浪云做网站做婚姻介绍网站赚钱吗
  • 网站开发员一月多少工资东莞网站建设专业品牌
  • 哪个网站找做软件下载淘宝详情页设计
  • 龙岗区网站建设公司高并发系统架构
  • 网站设计规划方案做公众号封面的网站
  • html网站用什么空间正邦设计有限公司
  • 中企建网站免费找订单的平台
  • 上市公司做网站有什么用营销网站有四大要素构成
  • 南京医院手机网站建设怎么自己做游戏
  • 网站设计公司 上广西网站建设在线
  • aspcms网站打不开深圳找网站建设公司
  • 泉州网站建设价钱将自己做的网站发布到
  • 乐清手机网站网上服装定制网站
  • 如何做提卡网站衡阳专业seo公司
  • 珠海 网站建设和推广重庆城乡建设信息网
  • 帮我们公司做网站微信分享 淘宝网站 怎么做
  • 黔西南北京网站建设17zwd一起做网站教学视频
  • 网站运营策略如何做做3dh春丽网站叫什么
  • 中国制造网网站特色qt科技感ui界面
  • 百度建网站多少钱ui设计属于视觉传达吗
  • 网站百度没收录北京市企业信用信息查询网
  • 中国域名门户网站阿里巴巴吧做网站
  • 智慧建设网站wordpress 插件 您没有足够的权限访问该页面
  • 网站升级页面连接设置标准通网站建设
  • 电子商务网站建设与维护的教学浅谈网站建设的目的和意义
  • 毕业设计做网站前端推广计划表
  • 仪征市建设工程网站做网站有一行一行写代码的吗
  • 网站托管服务方案医院门户网站开发
  • 最超值的锦州网站建设汕头地区做网站的