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

【时间处理】获取官方节假日数据的api接口,获取指定日期的节假日数据


获取指定日期的节假日信息

1、接口地址:http://api.goseek.cn/Tools/holiday?date=数字日期
2、返回数据:正常工作日对应结果为 0, 法定节假日对应结果为 1, 节假日调休补班对应的结果为 2,休息日对应结果为 3 
3、节假日数据说明:本接口包含2017年起的中国法定节假日数据,数据来源国务院发布的公告,每年更新1次,确保数据最新
4、示例:
http://api.goseek.cn/Tools/holiday?date=20170528 
返回数据:

{"code":10000,"data":1}     


免费节假日API 开源了,可以离线调用, 可以集成到自己系统中

功能

  • 检查具体日期是否为节假日,工作日对应结果为 0, 休息日对应结果为 1, 节假日对应的结果为 2;(对应支付工资比例分别为 100%, 200% 和 300%,以方便程序计算。计算方法:基本工资* (1+结果数值))
  • 获取具体月份下的节假日情况,只返回休息日或者节假日数据;
  • 可同时传递一个或者多个日期(月份);
  • 支持 2009 年起至 2019 年中国法定节假日,以国务院发布的公告为准,随时调整及增加:http://www.gov.cn/zfwj/bgtfd.htm或http://www.gov.cn/zhengce/xxgkzl.htm

注:当结果为数组时默认返回数据为 json 格式。

开源说明

注:原百度节假日API即为本人提供,后百度apistore禁止个人开发者所以才有此独立接口。鉴于免费版访问量过大对于服务器压力过大现将免费版开源供大家离线调用。

开源的功能为最核心的内容.大家可自行根据需要进行二次开发。

仅有php版本,其它语言可以参考代码自行开发

使用说明

  1. 下载源码部署到到系统中直接调用?d=日期
  2. 离线调用方法
 include('include/dateapi.class.php');$api= new dateapi();$result= $api->getday($date);


实现代码:

import calendar
from  urllib import request
from random import randrange
import json
import timeyear = 2020
data_list = []
for month in range(1,13):week_list = calendar.monthcalendar(year,month)for i in week_list:for j in i:if j!=0:# 法定节假日信息# target_url = "http://www.easybots.cn/api/holiday.php?d=%s%02d%02d"% + current_datecurrent_date = "%s%02d%02d"%(year,month,j)target_url = "http://api.goseek.cn/Tools/holiday?date=" + current_date# target_url = "http://tool.bitefu.net/jiari?date=%s%02d%02d" + current_dateprint(target_url)headers = [("Accept","text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3"),("Accept-Encoding", "gzip, deflate"),("Accept-Language", "zh-CN,zh;q=0.9"),("Connection", "keep-alive"),("Host", "api.goseek.cn"),("Upgrade-Insecure-Requests", 1),("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36")]opener = request.build_opener()opener.addheaders = headersresp = opener.open(target_url).read()# resp = request.urlopen(url=target_url).read()print(resp)res = json.loads(resp)res["date"] = current_dateprint(res)# resp = str(resp)[2:-1].replace("\"","'")data_list.append(res)time.sleep(randrange(2,10))data = json.dumps(data_list)
with open("{}cla.json".format(year),"w",encoding="utf-8") as fp:fp.write(data)with open("{}cla.json".format(year),"r",encoding="utf-8") as fp:a = fp.read()b = json.loads(a)print(a)for i in b:print(i)

http://www.xdnf.cn/news/838585.html

相关文章:

  • 怎么才能获取企业工商数据和企业联系方式?
  • 斯坦福大学11月份的论文《NECST:Nerual Joint Source-Channel Coding》
  • 知识 | 你给英文杂志投稿时,知道各种Editor是什么吗?
  • MySQL中 replace与replace into的区别与使用方法(干货分享)
  • vb-listbox用法
  • Design pattern 第一讲 基础知识
  • Three.js进阶篇之2 - 动画
  • ARM处理器选型指南:选ARM7还是选Cortex-M3 ?
  • 使用django实现京东部分商品数据的爬虫并存入自带的sqlite数据库
  • Quartz之基本使用
  • equals方法与hashCode方法
  • 25款最好的数据恢复软件测评分析与对比
  • synchronized
  • Scale和Resolution的含义及转换算法
  • CRM 系统详解:定义、功能与应用全解析
  • 不看后悔!国内外程序员接单平台大合集!带你一次性了解各个热门接单平台!
  • Unable to open sync connection!(转)
  • 0基础小白学C语言看这一篇就够了(C语言详讲万字!!!)
  • 【愚公系列】用友系列之YonBuilder低代码平台概论和基本使用
  • Linux使用Backspace(消除键)键时出现^H 解决方法
  • 软件测试 —— 冒烟测试(Smoke Test,ST)_软件测试行业 冒烟用例
  • RBI远程浏览器隔离技术
  • 关于Applets
  • 错误应用程序 httpd.exe_错误模块 php5ts.dll,apache+php环境,时遇到php5ts.dll错误
  • app跳转到京东的某个页面
  • 书友必备EPUB阅读软件
  • 绘图软件:Autodesk AutoCAD 2012 简体中文正式版下载(32/64位)+有效破解激活注册机
  • 【Stable diffusion教程】AutoDL云部署超详细步骤说明【外婆都会】
  • Struts2之拦截器(拦截客户端对Action访问)
  • 学习python需要多长时间?