feat(route): add Guangzhou Metro (#12533)
* feat(route): add Guangzhou Metro * fix: shorthand type conversions * fix: update as comments
This commit is contained in:
parent
ecfeafbff7
commit
42ff32c757
|
|
@ -28,6 +28,12 @@ If the city name contains a space like `Mexico City`, replace the space with `%2
|
|||
:paramsDesc="['state of the exhibition: `current`,`past`, or `upcoming`, the default value is `current`']"
|
||||
/>
|
||||
|
||||
## Guangzhou Metro
|
||||
|
||||
### News
|
||||
|
||||
<RouteEn author="HankChow" example="/guangzhoumetro/news" path="/guangzhoumetro/news" />
|
||||
|
||||
## Hopper
|
||||
|
||||
### Flight Deals
|
||||
|
|
|
|||
|
|
@ -89,6 +89,12 @@ IATA 国际航空运输协会机场代码,参见[维基百科 国际航空运
|
|||
|
||||
</Route>
|
||||
|
||||
## 广州地铁
|
||||
|
||||
### 新闻
|
||||
|
||||
<Route author="HankChow" example="/guangzhoumetro/news" path="/guangzhoumetro/news"/>
|
||||
|
||||
## 国家地理
|
||||
|
||||
### 分类
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/news': ['HankChow'],
|
||||
};
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const newsUrl = 'https://www.gzmtr.com/ygwm/xwzx/gsxw/';
|
||||
const response = await got(newsUrl);
|
||||
const data = response.data;
|
||||
|
||||
const $ = cheerio.load(data);
|
||||
const list = $('ul.ag_h_w li')
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
const url = newsUrl + item.find('a').attr('href').substr(2);
|
||||
const title = item.find('a').text();
|
||||
const publishTime = parseDate(item.find('span').text());
|
||||
return {
|
||||
title,
|
||||
link: url,
|
||||
author: '广州地铁',
|
||||
pubtime: publishTime,
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
ctx.state.data = {
|
||||
title: '广州地铁新闻',
|
||||
url: newsUrl,
|
||||
description: '广州地铁新闻',
|
||||
item: list.map((item) => ({
|
||||
title: item.title,
|
||||
pubDate: item.pubtime,
|
||||
link: item.link,
|
||||
author: item.author,
|
||||
})),
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
module.exports = {
|
||||
'gzmtr.com': {
|
||||
_name: '广州地铁',
|
||||
www: [
|
||||
{
|
||||
title: '新闻',
|
||||
docs: 'https://docs.rsshub.app/travel.html#guang-zhou-di-tie',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = function (router) {
|
||||
router.get('/news', require('./news'));
|
||||
};
|
||||
Loading…
Reference in New Issue