diff --git a/lib/router.js b/lib/router.js index 3c61cad84..233042441 100644 --- a/lib/router.js +++ b/lib/router.js @@ -928,7 +928,7 @@ router.get('/mcbbs/forum/:type', lazyloadRouteHandler('./routes/mcbbs/forum')); router.get('/mcbbs/post/:tid/:authorid?', lazyloadRouteHandler('./routes/mcbbs/post')); // 每日猪价 -router.get('/pork-price', lazyloadRouteHandler('./routes/pork-price')); +// router.get('/pork-price', lazyloadRouteHandler('./routes/pork-price')); // NOI 全国青少年信息学奥林匹克竞赛 router.get('/noi', lazyloadRouteHandler('./routes/noi')); diff --git a/lib/routes-deprecated/pork-price/index.js b/lib/routes/zhuwang/index.ts similarity index 62% rename from lib/routes-deprecated/pork-price/index.js rename to lib/routes/zhuwang/index.ts index 7ae6c4a0d..dbf79a10e 100644 --- a/lib/routes-deprecated/pork-price/index.js +++ b/lib/routes/zhuwang/index.ts @@ -1,25 +1,22 @@ -const got = require('@/utils/got'); +import got from '@/utils/got'; -const base_url = 'https://zhujia.zhuwang.cc/'; -module.exports = async (ctx) => { +export default async (ctx) => { + const baseUrl = 'https://zhujia.zhuwang.cc/'; const now = new Date(); const date = `${now.getFullYear()}-${now.getMonth() + 1}-${now.getDate()}`; - const response = await got({ - method: 'get', - url: `https://zhujia.zhuwang.cc/api/chartData?areaId=-1`, - headers: { - Referer: base_url, + const response = await got(`${baseUrl}/api/chartData`, { + searchParams: { + areaId: -1, }, }); const names = { pigprice: '生猪(外三元)', - pig_local: '生猪(土杂猪)', pig_in: '生猪(内三元)', + pig_local: '生猪(土杂猪)', }; - const priceItems = []; - for (const key of Object.keys(names)) { + const priceItems = Object.entries(names).map(([key, name], i) => { const items = response.data[key]; const today = items.at(-1); const yesterday = items.at(-2); @@ -32,18 +29,18 @@ module.exports = async (ctx) => { description = '较昨日价格持平'; } - priceItems.push({ - title: `${date} ${names[key]} ${today}元/公斤. ${description}`, + return { + title: `${date} ${name} ${today}元/公斤. ${description}`, description, - link: base_url, - guid: `${date} ${names[key]}`, - }); - } + link: `https://xt.yangzhu.vip/manage/datamap/ptype/${i + 1}/areano/-1.html`, + guid: `${date} ${name}`, + }; + }); - ctx.state.data = { + ctx.set('data', { title: `全国今日生猪价格`, desription: '中国养猪网猪价频道是中国猪价权威平台,提供每日猪评,猪价和行情分析,并且预测猪价和分析每天的猪价排行。', - link: base_url, + link: baseUrl, item: priceItems, - }; + }); }; diff --git a/lib/routes/zhuwang/maintainer.ts b/lib/routes/zhuwang/maintainer.ts new file mode 100644 index 000000000..3dda4d2e6 --- /dev/null +++ b/lib/routes/zhuwang/maintainer.ts @@ -0,0 +1,3 @@ +export default { + '/zhuwang/zhujia': ['importcjj'], +}; diff --git a/lib/routes/zhuwang/radar.ts b/lib/routes/zhuwang/radar.ts new file mode 100644 index 000000000..35337ab2c --- /dev/null +++ b/lib/routes/zhuwang/radar.ts @@ -0,0 +1,13 @@ +export default { + 'zhuwang.cc': { + _name: '中国养猪网', + zhujia: [ + { + title: '每日生猪价格更新', + docs: 'https://docs.rsshub.app/routes/shopping#zhong-guo-yang-zhu-wang', + source: '/', + target: '/zhuwang/zhujia', + }, + ], + }, +}; diff --git a/lib/routes/zhuwang/router.ts b/lib/routes/zhuwang/router.ts new file mode 100644 index 000000000..b6b6a782c --- /dev/null +++ b/lib/routes/zhuwang/router.ts @@ -0,0 +1,3 @@ +export default (router) => { + router.get('/zhujia', './'); +}; diff --git a/website/docs/routes/other.mdx b/website/docs/routes/other.mdx index 23520205d..2dc080e65 100644 --- a/website/docs/routes/other.mdx +++ b/website/docs/routes/other.mdx @@ -825,12 +825,6 @@ Specify options (in the format of query string) in parameter `routeParams` param -## 每日生猪价格 {#mei-ri-sheng-zhu-jia-ge} - -### 每日生猪价格更新 {#mei-ri-sheng-zhu-jia-ge-mei-ri-sheng-zhu-jia-ge-geng-xin} - - - ## 米坛社区 {#mi-tan-she-qu} ### 表盘更新 {#mi-tan-she-qu-biao-pan-geng-xin} diff --git a/website/docs/routes/shopping.mdx b/website/docs/routes/shopping.mdx index 6f785087a..3b611d111 100644 --- a/website/docs/routes/shopping.mdx +++ b/website/docs/routes/shopping.mdx @@ -646,3 +646,9 @@ For instance, in `https://www.zagg.com/en_us/new-arrivals?brand=164&cat=3038%2C3 ### 搜索 {#zheng-ban-zhong-guo-sou-suo} + +## 中国养猪网 {#zhong-guo-yang-zhu-wang} + +### 每日生猪价格更新 {#zhong-guo-yang-zhu-wang-mei-ri-sheng-zhu-jia-ge-geng-xin} + +