feat: original link from WeChat and better performance (#2660)

* fix: original link from wechat

* fix: original link from wechat

* fix: original link from wechat

* fix: original link from WeChat and better performance
This commit is contained in:
枪鱼
2019-07-22 15:55:02 +08:00
committed by DIYgod
parent 2ffb5023a4
commit fcce45388f

View File

@@ -1,4 +1,5 @@
const got = require('@/utils/got');
const he = require('he');
const cheerio = require('cheerio');
const date = require('@/utils/date');
@@ -38,15 +39,20 @@ module.exports = async (ctx) => {
.attr('href')}`;
const response = await ctx.cache.tryGet(link, async () => (await got.get(link)).data);
const article = cheerio.load(response);
const matchs = /"(url|temp_url)":"([^"]+mp\.weixin\.qq\.com[^"]+)"/.exec(response);
let weixinLink = '';
if (matchs && matchs[2]) {
weixinLink = he.unescape(unescape(matchs[2].replace(/\\u/g, '%u')));
}
const single = {
title: $(e)
.find('.post-item__title')
.text()
.trim(),
link,
link: weixinLink || link,
description: article('#content').html(),
pubDate,
author,