fix(route): recover zhuwang (#14674)

This commit is contained in:
Tony 2024-03-06 00:48:35 +08:00 committed by GitHub
parent c314a56fdc
commit 641a8e62fb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 43 additions and 27 deletions

View File

@ -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'));

View File

@ -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,
};
});
};

View File

@ -0,0 +1,3 @@
export default {
'/zhuwang/zhujia': ['importcjj'],
};

View File

@ -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',
},
],
},
};

View File

@ -0,0 +1,3 @@
export default (router) => {
router.get('/zhujia', './');
};

View File

@ -825,12 +825,6 @@ Specify options (in the format of query string) in parameter `routeParams` param
<Route author="snipersteve" example="/law/jctd" path="/law/jctd" notOperational="1" />
## 每日生猪价格 {#mei-ri-sheng-zhu-jia-ge}
### 每日生猪价格更新 {#mei-ri-sheng-zhu-jia-ge-mei-ri-sheng-zhu-jia-ge-geng-xin}
<Route author="importcjj" example="/pork-price" path="/pork-price" />
## 米坛社区 {#mi-tan-she-qu}
### 表盘更新 {#mi-tan-she-qu-biao-pan-geng-xin}

View File

@ -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}
<Route author="sanmmm nczitzk" example="/getitfree/search/windows" path="/getitfree/search/:keyword" paramsDesc={['关键字']} radar="1" />
## 中国养猪网 {#zhong-guo-yang-zhu-wang}
### 每日生猪价格更新 {#zhong-guo-yang-zhu-wang-mei-ri-sheng-zhu-jia-ge-geng-xin}
<Route author="importcjj" example="/zhuwang/zhujia" path="/zhuwang/zhujia" radar="1" />