forked from DIYgod/RSSHub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(route): mpaypass news (DIYgod#9367)
* fix(route): mpaypass news * refactor: migrate to v2 * fix: parseDate
- Loading branch information
1 parent
e008efd
commit a03175d
Showing
8 changed files
with
94 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
'/main/:type?': ['zhuan-zhu'], | ||
'/news': ['LogicJake', 'genghis-yang'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
const { parseDate } = require('@/utils/parse-date'); | ||
const timezone = require('@/utils/timezone'); | ||
|
||
module.exports = async (ctx) => { | ||
const link = 'http://m.mpaypass.com.cn'; | ||
const listData = await got(link); | ||
const $list = cheerio.load(listData.data); | ||
ctx.state.data = { | ||
title: '新闻 - 移动支付网', | ||
link, | ||
language: 'zh-CN', | ||
item: await Promise.all( | ||
$list('.Newslist-li') | ||
.map((_, el) => { | ||
const $el = $list(el); | ||
const $a = $el.find('.Newslist-title a'); | ||
const href = $a.attr('href'); | ||
const title = $a.text(); | ||
const date = $el.find('.Newslist-time span').text(); | ||
|
||
return ctx.cache.tryGet(href, async () => { | ||
const contentData = await got.get(href); | ||
const $content = cheerio.load(contentData.data); | ||
const description = $content('.newslist-body').html(); | ||
|
||
return { | ||
title, | ||
description, | ||
link: href, | ||
pubDate: timezone(parseDate(date), +8), | ||
}; | ||
}); | ||
}) | ||
.get() | ||
), | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module.exports = { | ||
'mpaypass.com.cn': { | ||
_name: '移动支付网', | ||
'.': [ | ||
{ | ||
title: '新闻', | ||
docs: 'https://docs.rsshub.app/new-media.html#yi-dong-zhi-fu-wang', | ||
source: '/', | ||
target: '/mpaypass/news', | ||
}, | ||
{ | ||
title: '分类', | ||
docs: 'https://docs.rsshub.app/new-media.html#yi-dong-zhi-fu-wang', | ||
source: ['/:type', '/'], | ||
target: (params) => `/mpaypass/main/${params.type.replace('.html', '')}`, | ||
}, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = (router) => { | ||
router.get('/main/:type?', require('./main')); | ||
router.get('/news', require('./news')); | ||
}; |