Glanceway Glanceway
جميع المصادر

财联社电报

المالية v1.0.0

财联社电报快讯

@codytseng #finance #news #chinese #market

الشيفرة المصدرية

version: 1.0.0
name: 财联社电报
description: 财联社电报快讯
author: codytseng
author_url: https://github.com/codytseng
category: Finance
tags:
  - finance
  - news
  - chinese
  - market
module.exports = async (api) => {
  async function fetchData() {
    const res = await api.fetch(
      "https://www.cls.cn/nodeapi/telegraphList?app=CailianpressWeb&os=web&refresh_type=1&rn=200&sv=8.4.6",
      {
        headers: { Referer: "https://www.cls.cn/" },
      },
    );
    if (!res.ok || !res.json) {
      throw new Error(`Failed to fetch CLS telegraph (HTTP ${res.status})`);
    }

    const items = res.json.data.roll_data
      .filter((item) => item.title)
      .map((item) => ({
        id: String(item.id),
        title: item.title,
        subtitle: item.brief,
        url: item.shareurl,
        timestamp: item.ctime,
      }));

    api.emit(items);
  }

  await fetchData();

  return {
    refresh: fetchData,
  };
};