logo科技微讯

24节气数据

作者:科技微讯
日期:2022-01-08
📝 笔记

GitHub 有人分享了各年 24 节气数据

可以用下面这种方法获取各年的数据:

const got = require("got");

async function app() {
  const years = [2022, 2023, 2024, 2025, 2026, 2027, 2028, 2029, 2030];
  const array = years.map(async (year) => {
    const url = `https://raw.githubusercontent.com/hungtcs/traditional-chinese-calendar-database/master/database/json/${year}.json`;
    const json = await got(url).json();
    const list = json.filter((item) => item.solarTerm);
    return {
      year: year,
      list: list,
    };
  });
  const result = await Promise.all(array);
  fs.writeFileSync("./jieqi.json", JSON.stringify(result));
}

app();
donation赞赏
thumbsup0
thumbsdown0
暂无评论