feat(route): qiyoujiage (#11928)
This commit is contained in:
+16
-6
@@ -717,6 +717,22 @@ type 为 all 时,category 参数不支持 cost 和 free
|
||||
|
||||
</Route>
|
||||
|
||||
## 汽油价格网
|
||||
|
||||
### 今日油价查询
|
||||
|
||||
<Route author="TonyRL" example="/qiyoujiage/shanghai" path="/qiyoujiage/:path*" :paramsDesc="['路径']">
|
||||
|
||||
::: tip 提示
|
||||
|
||||
路径处填写对应页面 URL 中 `http://www.qiyoujiage.com/` 和 `.shtml` 之间的字段。下面是一个例子。
|
||||
|
||||
若订阅 [福建漳州龙海今日油价](http://www.qiyoujiage.com/fujian/zhangzhou/longhai.shtml) 则将对应页面 URL <http://www.qiyoujiage.com/fujian/zhangzhou/longhai.shtml> 中 `http://www.qiyoujiage.com/` 和 `.shtml` 之间的字段 `fujian/zhangzhou/longhai` 作为路径填入。此时路由为 [`/qiyoujiage/fujian/zhangzhou/longhai`](https://rsshub.app/qiyoujiage/fujian/zhangzhou/longhai)
|
||||
|
||||
:::
|
||||
|
||||
</Route>
|
||||
|
||||
## 且听风吟福利
|
||||
|
||||
### 分类
|
||||
@@ -925,12 +941,6 @@ type 为 all 时,category 参数不支持 cost 和 free
|
||||
|
||||
<Route author="kt286" example="/mail/imap/rss@rsshub.app" path="/mail/imap/:email" :paramsDesc="['邮箱账号']" selfhost="1"/>
|
||||
|
||||
## 油价
|
||||
|
||||
### 今日油价
|
||||
|
||||
<Route author="xyqfer" example="/oilprice/shanghai" path="/oilprice/:area" :paramsDesc="['地区拼音,详见[成品油价格网](http://oil.usd-cny.com/)']"/>
|
||||
|
||||
## 有据
|
||||
|
||||
### 最新文章列表
|
||||
|
||||
@@ -928,9 +928,6 @@ router.get('/chouti/:subject?', lazyloadRouteHandler('./routes/chouti'));
|
||||
// Westore
|
||||
router.get('/westore/new', lazyloadRouteHandler('./routes/westore/new'));
|
||||
|
||||
// 油价
|
||||
router.get('/oilprice/:area', lazyloadRouteHandler('./routes/oilprice'));
|
||||
|
||||
// nHentai
|
||||
router.get('/nhentai/search/:keyword/:mode?', lazyloadRouteHandler('./routes/nhentai/search'));
|
||||
router.get('/nhentai/:key/:keyword/:mode?', lazyloadRouteHandler('./routes/nhentai/other'));
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const iconv = require('iconv-lite');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { area } = ctx.params;
|
||||
const link = 'http://oil.usd-cny.com/';
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: link,
|
||||
responseType: 'buffer',
|
||||
});
|
||||
const $ = cheerio.load(iconv.decode(response.data, 'gb2312'));
|
||||
const $list = $('.content').eq(0).find('table tbody tr');
|
||||
const resultItem = [];
|
||||
let areaName = '';
|
||||
const updateTime = $('.time').text().split(':')[1];
|
||||
const labelList = $list
|
||||
.eq(1)
|
||||
.find('td')
|
||||
.slice(1)
|
||||
.map((index, item) => $(item).text())
|
||||
.get();
|
||||
|
||||
for (let i = 2; i < $list.length; i++) {
|
||||
if ($list.eq(i).find('td a').attr('href').includes(`oil.usd-cny.com/${area}.htm`)) {
|
||||
const $item = $list.eq(i);
|
||||
areaName = $item.find('td a').text();
|
||||
const { description, content } = labelList.reduce(
|
||||
(descObj, label, index) => {
|
||||
const price = $item
|
||||
.find('td')
|
||||
.eq(index + 1)
|
||||
.text();
|
||||
|
||||
descObj.description += `
|
||||
<strong>${label}:</strong> ${price}<br>
|
||||
`;
|
||||
descObj.content += `${label}-${price}; `;
|
||||
|
||||
return descObj;
|
||||
},
|
||||
{
|
||||
description: '',
|
||||
content: '',
|
||||
}
|
||||
);
|
||||
|
||||
resultItem.push({
|
||||
title: `${updateTime}-${areaName}油价: ${content}`,
|
||||
description,
|
||||
link,
|
||||
guid: updateTime,
|
||||
pubDate: new Date(updateTime).toUTCString(),
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ctx.state.data = {
|
||||
title: `今日油价查询-${areaName}`,
|
||||
description: '今日汽油价格查询 最新柴油油价实时行情',
|
||||
link,
|
||||
item: resultItem,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
'/:path+': ['TonyRL'],
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const md5 = require('@/utils/md5');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { path } = ctx.params;
|
||||
const link = `http://www.qiyoujiage.com/${path}.shtml`;
|
||||
|
||||
const { data: response } = await got(link);
|
||||
const $ = cheerio.load(response);
|
||||
|
||||
const priceText = $('#youjia').text();
|
||||
const item = [
|
||||
{
|
||||
title: priceText,
|
||||
description: $('#youjia').html(),
|
||||
link,
|
||||
guid: `${link}#${md5(priceText)}`,
|
||||
},
|
||||
];
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('title').text(),
|
||||
description: $('meta[name="Description"]').attr('content'),
|
||||
link,
|
||||
item,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
'qiyoujiage.com': {
|
||||
_name: '汽油价格网',
|
||||
'.': [
|
||||
{
|
||||
title: '今日油价查询',
|
||||
docs: 'https://docs.rsshub.app/other.html#qi-you-jia-ge-wang',
|
||||
source: ['/*'],
|
||||
target: (_, url) => `/qiyoujiage${new URL(url).pathname.replace('.shtml', '')}`,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = (router) => {
|
||||
router.get('/:path+', require('./price'));
|
||||
};
|
||||
Reference in New Issue
Block a user