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): 腾讯企鹅号正文乱码 (DIYgod#12130)
- Loading branch information
Showing
7 changed files
with
56 additions
and
63 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,44 @@ | ||
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 mid = ctx.params.mid; | ||
const response = await got(`https://pacaio.match.qq.com/om/mediaArticles?mid=${mid}&num=10&page=0`); | ||
const reponse = response.data; | ||
const title = reponse.mediainfo.name; | ||
const description = reponse.mediainfo.intro; | ||
const list = reponse.data; | ||
|
||
const items = await Promise.all( | ||
list.map((item) => { | ||
const title = item.title; | ||
const pubDate = timezone(parseDate(item.time), +8); | ||
const itemUrl = item.vurl; | ||
const author = item.source; | ||
const abstract = item.abstract; | ||
|
||
return ctx.cache.tryGet(itemUrl, async () => { | ||
const response = await got(itemUrl); | ||
const $ = cheerio.load(response.data); | ||
const article = $('div.content-article'); | ||
|
||
return { | ||
title, | ||
description: article.html() || abstract, | ||
link: itemUrl, | ||
author, | ||
pubDate, | ||
}; | ||
}); | ||
}) | ||
); | ||
|
||
ctx.state.data = { | ||
title, | ||
description, | ||
link: `https://new.qq.com/omn/author/${mid}`, | ||
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
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