From 521862793e8f7f2e5ef952e8a1aff1b256256b57 Mon Sep 17 00:00:00 2001 From: Tony Date: Tue, 5 Apr 2022 07:13:24 -0700 Subject: [PATCH] feat(route)!: remove wechat/csm wechat/wjdn (#9472) --- docs/new-media.md | 8 ----- lib/routes/tencent/wechat/csm.js | 59 ------------------------------- lib/routes/tencent/wechat/wjdn.js | 28 --------------- 3 files changed, 95 deletions(-) delete mode 100644 lib/routes/tencent/wechat/csm.js delete mode 100644 lib/routes/tencent/wechat/wjdn.js diff --git a/docs/new-media.md b/docs/new-media.md index 6a0d3c7d4..b29581aaa 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -3342,10 +3342,6 @@ column 为 third 时可选的 category: -### 公众号(传送门来源) - - - ### 公众号(CareerEngine 来源) @@ -3382,10 +3378,6 @@ column 为 third 时可选的 category: -### 公众号 (外接大脑来源) - - - ### 公众号 (wxnmh.com 来源) diff --git a/lib/routes/tencent/wechat/csm.js b/lib/routes/tencent/wechat/csm.js deleted file mode 100644 index 3fa9953c7..000000000 --- a/lib/routes/tencent/wechat/csm.js +++ /dev/null @@ -1,59 +0,0 @@ -const got = require('@/utils/got'); -const date = require('@/utils/date'); -const cheerio = require('cheerio'); - -module.exports = async (ctx) => { - const { id } = ctx.params; - - const link = `https://chuansongme.com/account/${id}`; - - const response = await got.get(link); - - const $ = cheerio.load(response.data); - - const items = await Promise.all( - $('.feed_item') - .slice(0, 10) - .get() - .map(async (e) => { - const pubDate = date($(e).find('.timestamp').text().trim(), 8); - - const link = `https://chuansongme.com${$(e).find('.question_link').attr('href')}`; - - const response = await ctx.cache.tryGet(link, async () => (await got.get(link)).data); - - const article = cheerio.load(response); - - article('[style="display: none;"], [style=" display: none;"], [style="display: none"]').each((i, e) => { - article(e).remove(); - }); - - article('#js_content img').each((index, elem) => { - const $elem = article(elem); - - const imgSrc = $elem.attr('data-original') || $elem.attr('src'); - if (imgSrc) { - const realSrc = imgSrc.replace(/^https:\/\/img.chuansongme.com\//, 'https://mmbiz.qpic.cn/').replace(/^http.?\/\/img\d+.store.sogou.com.*url=(.*)$/, '$1'); - $elem.attr('src', realSrc); - } - }); - - const single = { - title: article('#activity-name').text(), - link, - description: article('#js_content').html(), - pubDate, - author: article('#meta_content > span:nth-child(2)').text(), - }; - - return Promise.resolve(single); - }) - ); - - ctx.state.data = { - title: `微信公众号 - ${$('.inline_editor_content').first().text().trim()}`, - link, - description: $('.inline_editor_content').last().text().trim(), - item: items, - }; -}; diff --git a/lib/routes/tencent/wechat/wjdn.js b/lib/routes/tencent/wechat/wjdn.js deleted file mode 100644 index a22d171c7..000000000 --- a/lib/routes/tencent/wechat/wjdn.js +++ /dev/null @@ -1,28 +0,0 @@ -const got = require('@/utils/got'); - -module.exports = async (ctx) => { - const { id } = ctx.params; - if (!id) { - throw Error('Bad category. See docs'); - } - - const currentUrl = `https://www.waijiedanao.com/api/posts?profile=${id}&page=1&limit=20`; - const response = await got({ - method: 'get', - url: currentUrl, - }); - - const title = response.data.data[0].profile.title; - const list = response.data.data.map((item) => ({ - title: item.title, - link: item.link, - description: item.digest, - pubDate: new Date(item.publishAt).toUTCString(), - })); - - ctx.state.data = { - title: `微信公众号 - ${title}`, - link: `https://www.waijiedanao.com/accountArtical?publicAccountId=${id}`, - item: list, - }; -};