-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create 1.txt * Add files via upload * Delete lib/v2/mtime directory * Add files via upload * Update multimedia.md * Update multimedia.md * Update and rename lib/v2/mtime/news.js to 自由/版本 2/mtime/news.js * Delete news.js * Add files via upload * Update multimedia.md * Update news.js * Update news.js * Update news.js * Update news.js * Update radar.js * Update radar.js * Update radar.js * Update news.js * Update news.js * Update news.js
- Loading branch information
Showing
5 changed files
with
73 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
'/mtime/news': ['TsSmartTT'], | ||
}; |
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,48 @@ | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
const timezone = require('@/utils/timezone'); | ||
const { parseDate } = require('@/utils/parse-date'); | ||
|
||
module.exports = async (ctx) => { | ||
const link = 'http://news.mtime.com/'; | ||
const response = await got({ | ||
method: 'get', | ||
url: link, | ||
}); | ||
const $ = cheerio.load(response.data); | ||
const list = $('ul.left-cont.fix li') | ||
.map((_, item) => { | ||
item = $(item); | ||
return { | ||
title: item.find('h4 a').text(), | ||
link: item.find('h4 a').attr('href'), | ||
}; | ||
}) | ||
.get(); | ||
|
||
const items = await Promise.all( | ||
list.map((item) => | ||
ctx.cache.tryGet(item.link, async () => { | ||
const detailResponse = await got({ | ||
method: 'get', | ||
url: item.link, | ||
}); | ||
const content = cheerio.load(detailResponse.data); | ||
|
||
content('.DRE-subject-wrapper').remove(); | ||
|
||
item.author = content('.editor').text().replace('编辑:', ''); | ||
item.description = content('.body').first().html(); | ||
item.pubDate = timezone(parseDate(content('.userCreateTime').text()), 8); | ||
|
||
return item; | ||
}) | ||
) | ||
); | ||
|
||
ctx.state.data = { | ||
title: 'Mtime时光网 - 资讯', | ||
link, | ||
item: items, | ||
}; | ||
}; |
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,13 @@ | ||
module.exports = { | ||
'mtime.com': { | ||
_name: '时光网', | ||
'news': [ | ||
{ | ||
title: '资讯', | ||
docs: 'https://docs.rsshub.app/multimedia.html#shi-guang-wang', | ||
source: '/', | ||
target: '/mtime/news', | ||
}, | ||
], | ||
}, | ||
}; |
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,3 @@ | ||
module.exports = function (router) { | ||
router.get('/news', require('./news')); | ||
}; |