Skip to content

Commit

Permalink
feat(route): qiyoujiage (#11928)
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyRL committed Feb 21, 2023
1 parent c2f2a15 commit e2a1214
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 75 deletions.
22 changes: 16 additions & 6 deletions docs/other.md
Original file line number Diff line number Diff line change
Expand Up @@ -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>

## 且听风吟福利

### 分类
Expand Down Expand Up @@ -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/)']"/>

## 有据

### 最新文章列表
Expand Down
3 changes: 0 additions & 3 deletions lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
66 changes: 0 additions & 66 deletions lib/routes/oilprice/index.js

This file was deleted.

3 changes: 3 additions & 0 deletions lib/v2/qiyoujiage/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/:path+': ['TonyRL'],
};
28 changes: 28 additions & 0 deletions lib/v2/qiyoujiage/price.js
Original file line number Diff line number Diff line change
@@ -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,
};
};
13 changes: 13 additions & 0 deletions lib/v2/qiyoujiage/radar.js
Original file line number Diff line number Diff line change
@@ -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', '')}`,
},
],
},
};
3 changes: 3 additions & 0 deletions lib/v2/qiyoujiage/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = (router) => {
router.get('/:path+', require('./price'));
};

0 comments on commit e2a1214

Please sign in to comment.