rsshub
Version:
Make RSS Great Again!
56 lines (55 loc) • 1.69 kB
JavaScript
import { t as rofetch } from "./ofetch-C3ts-Hud.mjs";
import { t as parseDate } from "./parse-date-Cr0wQjV_.mjs";
import { t as cache_default } from "./cache-BkqOokyU.mjs";
import { t as timezone } from "./timezone-BBvDwS_3.mjs";
import { load } from "cheerio";
//#region lib/routes/my-formosa/index.ts
const route = {
path: "/",
categories: ["new-media"],
example: "/my-formosa",
parameters: {},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{ source: ["m.my-formosa.com.tw/"] }],
name: "首頁",
maintainers: ["dzx-dzx"],
handler,
url: "m.my-formosa.com.tw"
};
async function handler() {
const rootUrl = "https://m.my-formosa.com.tw";
const $ = load(await rofetch(rootUrl));
const items = await Promise.all($("ul.local-list li .cont h1 a").toArray().map((item) => {
const $item = $(item);
const title = $item.text();
const link = new URL($item.attr("href"), rootUrl).href;
return cache_default.tryGet(link, async () => {
const $ = load(await rofetch(link));
const pubDate = $(".news_header .info").text().match(/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/)?.[0];
const media = $.html($(".news_header > img, .news_header > .media"));
const summary = $.html($(".product > h2"));
return {
title,
link,
author: $(".cont h1 a").text(),
category: [$(".story_header button").text()],
pubDate: pubDate ? timezone(parseDate(pubDate), 8) : void 0,
description: media + summary + ($(".body").html() ?? "")
};
});
}));
return {
title: $("title").text(),
link: rootUrl,
item: items
};
}
//#endregion
export { route };