From 683121d071632b2ed02aad22eb770dbc0ad75aac Mon Sep 17 00:00:00 2001 From: Tony Date: Wed, 1 Apr 2026 07:16:50 +0800 Subject: [PATCH] feat(route): add tw-nongmu (#21578) * feat(route): add tw-nongmu * fix: add image * Update market.ts * Update market.ts --- lib/routes/tw-nongmu/market.ts | 51 +++++++++++++++++++++++++++++++ lib/routes/tw-nongmu/namespace.ts | 7 +++++ 2 files changed, 58 insertions(+) create mode 100644 lib/routes/tw-nongmu/market.ts create mode 100644 lib/routes/tw-nongmu/namespace.ts diff --git a/lib/routes/tw-nongmu/market.ts b/lib/routes/tw-nongmu/market.ts new file mode 100644 index 000000000..1167ed785 --- /dev/null +++ b/lib/routes/tw-nongmu/market.ts @@ -0,0 +1,51 @@ +import { load } from 'cheerio'; + +import type { Route } from '@/types'; +import ofetch from '@/utils/ofetch'; +import { parseDate } from '@/utils/parse-date'; +import { finishArticleItem } from '@/utils/wechat-mp'; + +export const route: Route = { + path: '/market', + categories: ['other'], + example: '/tw-nongmu/market', + radar: [ + { + source: ['www.tw-nongmu.com/market.html', 'www.tw-nongmu.com/'], + }, + ], + name: '鱼价行情', + maintainers: ['TonyRL'], + handler, + url: 'www.tw-nongmu.com/market.html', +}; + +async function handler() { + const baseUrl = 'https://www.tw-nongmu.com'; + const link = `${baseUrl}/market.html`; + + const response = await ofetch(link); + const $ = load(response); + + const list = $('.list-list li') + .toArray() + .map((item) => { + const $item = $(item); + const a = $item.find('a'); + return { + title: a.text(), + link: a.attr('href')!, + pubDate: parseDate($item.find('.date').text(), 'YYYY年MM月DD日'), + }; + }); + + const items = await Promise.all(list.map((item) => finishArticleItem(item))); + + return { + title: $('head title').text(), + link, + language: $('html').attr('lang') as const, + image: `${baseUrl}/favicon.ico`, + item: items, + }; +} diff --git a/lib/routes/tw-nongmu/namespace.ts b/lib/routes/tw-nongmu/namespace.ts new file mode 100644 index 000000000..8953d24bd --- /dev/null +++ b/lib/routes/tw-nongmu/namespace.ts @@ -0,0 +1,7 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '通威农业发展', + url: 'www.tw-nongmu.com', + lang: 'zh-CN', +};