From 955b0227067a60dfc403f8b40b37ce6e88e50879 Mon Sep 17 00:00:00 2001 From: Henry Wang Date: Sat, 29 Feb 2020 12:04:28 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=A7=BB=E9=99=A4=E8=85=BE=E8=AE=AF?= =?UTF-8?q?=E5=A4=A7=E5=AE=B6=20(#4104)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RIP 腾讯大家 --- docs/new-media.md | 14 ------ lib/router.js | 5 --- lib/routes/tencent/dajia/author.js | 52 ---------------------- lib/routes/tencent/dajia/index.js | 66 ---------------------------- lib/routes/tencent/dajia/zhuanlan.js | 54 ----------------------- 5 files changed, 191 deletions(-) delete mode 100644 lib/routes/tencent/dajia/author.js delete mode 100644 lib/routes/tencent/dajia/index.js delete mode 100644 lib/routes/tencent/dajia/zhuanlan.js diff --git a/docs/new-media.md b/docs/new-media.md index c20fee4c0f..9f9c101d82 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -804,20 +804,6 @@ Supported sub-sites: -## 腾讯大家 - -### 首页 - - - -### 作者作品 - - - -### 专栏 - - - ## 腾讯谷雨 ### 栏目 diff --git a/lib/router.js b/lib/router.js index cdf39c830f..74a8fec721 100644 --- a/lib/router.js +++ b/lib/router.js @@ -442,11 +442,6 @@ router.get('/oschina/topic/:topic', require('./routes/oschina/topic')); router.get('/aqk/vul', require('./routes/aqk/vul')); router.get('/aqk/:category', require('./routes/aqk/category')); -// 腾讯大家 -router.get('/dajia', require('./routes/tencent/dajia/index')); -router.get('/dajia/author/:uid', require('./routes/tencent/dajia/author')); -router.get('/dajia/zhuanlan/:uid', require('./routes/tencent/dajia/zhuanlan')); - // 腾讯游戏开发者社区 router.get('/gameinstitute/community/:tag?', require('./routes/tencent/gameinstitute/community')); diff --git a/lib/routes/tencent/dajia/author.js b/lib/routes/tencent/dajia/author.js deleted file mode 100644 index 93fa2fc542..0000000000 --- a/lib/routes/tencent/dajia/author.js +++ /dev/null @@ -1,52 +0,0 @@ -const got = require('@/utils/got'); -const cheerio = require('cheerio'); - -module.exports = async (ctx) => { - const uid = ctx.params.uid; - const link = `http://dajia.qq.com/author_personal.htm#!/${uid}`; - - const info_api = `http://i.match.qq.com/ninjayc/dajiazuozheye?action=zuojia&authorid=${uid}`; - const info_response = await got.get(info_api); - const author_name = info_response.data.data.author.name; - const description = info_response.data.data.author.description; - - const article_api = `http://i.match.qq.com/ninjayc/dajiawenzhanglist?action=wz&authorid=${uid}`; - const response = await got.get(article_api); - const list = response.data.data; - - const out = await Promise.all( - list.map(async (info) => { - const title = info.n_title; - const date = info.n_publishtime; - const itemUrl = info.n_mobile_url; - - const cache = await ctx.cache.get(itemUrl); - if (cache) { - return Promise.resolve(JSON.parse(cache)); - } - - const response = await got.get(itemUrl); - const $ = cheerio.load(response.data); - const description = $('#articleContent') - .html() - .replace(/src="\//g, 'src="http:/') - .trim(); - - const single = { - title: title, - link: itemUrl, - description: description, - pubDate: new Date(date).toUTCString(), - }; - ctx.cache.set(itemUrl, JSON.stringify(single)); - return Promise.resolve(single); - }) - ); - - ctx.state.data = { - title: `${author_name}的文章——腾讯大家`, - link: link, - description: description, - item: out, - }; -}; diff --git a/lib/routes/tencent/dajia/index.js b/lib/routes/tencent/dajia/index.js deleted file mode 100644 index bafc1d3f22..0000000000 --- a/lib/routes/tencent/dajia/index.js +++ /dev/null @@ -1,66 +0,0 @@ -const got = require('@/utils/got'); -const cheerio = require('cheerio'); -const iconv = require('iconv-lite'); - -module.exports = async (ctx) => { - const listRes = await got({ - method: 'get', - url: 'http://i.match.qq.com/ninjayc/dajia?action=getwenz&p=0&num=20&callback=', - headers: { - Referer: 'http://dajia.qq.com/m/index.html', - }, - }); - - const storyList = JSON.parse(listRes.data.slice(1, -2)).data; - const resultItem = await Promise.all( - storyList.map(async (story) => { - const mobileUrl = story.n_mobile_url; - const pcUrl = story.n_url; - const item = { - title: story.n_title, - description: '', - link: pcUrl, - guid: mobileUrl, - author: story.name, - pubDate: new Date(story.n_publishtime).toUTCString(), - }; - const key = `tx-dajia: ${mobileUrl}`; - const value = await ctx.cache.get(key); - - if (value) { - item.description = value; - } else { - const storyDetail = await got({ - method: 'get', - url: pcUrl, - headers: { - Referer: pcUrl, - }, - responseType: 'buffer', - }); - const $ = cheerio.load(iconv.decode(storyDetail.data, 'gb2312')); - $('#articleContent img').each(function(_, item) { - const $img = $(item); - const src = $img.attr('src'); - - if (!(src.startsWith('https://') || src.startsWith('http://'))) { - $img.attr('src', `https:${src}`); - } - - $img.attr('referrerpolicy', 'no-referrer'); - }); - - item.description = $('#articleContent').html(); - ctx.cache.set(key, item.description); - } - - return Promise.resolve(item); - }) - ); - - ctx.state.data = { - title: '腾讯大家', - link: 'http://dajia.qq.com/', - item: resultItem, - }; -}; diff --git a/lib/routes/tencent/dajia/zhuanlan.js b/lib/routes/tencent/dajia/zhuanlan.js deleted file mode 100644 index 64c3a727fc..0000000000 --- a/lib/routes/tencent/dajia/zhuanlan.js +++ /dev/null @@ -1,54 +0,0 @@ -const got = require('@/utils/got'); -const cheerio = require('cheerio'); - -module.exports = async (ctx) => { - const uid = ctx.params.uid; - const link = `http://dajia.qq.com/tanzi_diceng.htm#!/${uid}`; - - const info_api = `http://i.match.qq.com/ninjayc/dajialanmu?action=lanmu&channelid=${uid}`; - const info_response = await got.get(info_api); - const name = info_response.data.data.channel.n_cname; - const description = info_response.data.data.channel.n_describe; - - const article_api = `http://i.match.qq.com/ninjayc/dajiawenzhanglist?action=wz&channelid=${uid}`; - const response = await got.get(article_api); - const list = response.data.data; - - const out = await Promise.all( - list.map(async (info) => { - const title = info.n_title; - const date = info.n_publishtime; - const itemUrl = info.n_mobile_url; - const author = info.name; - - const cache = await ctx.cache.get(itemUrl); - if (cache) { - return Promise.resolve(JSON.parse(cache)); - } - - const response = await got.get(itemUrl); - const $ = cheerio.load(response.data); - const description = $('#articleContent') - .html() - .replace(/src="\//g, 'src="http:/') - .trim(); - - const single = { - title: title, - link: itemUrl, - description: description, - author: author, - pubDate: new Date(date).toUTCString(), - }; - ctx.cache.set(itemUrl, JSON.stringify(single)); - return Promise.resolve(single); - }) - ); - - ctx.state.data = { - title: `${name}——腾讯大家`, - link: link, - description: description, - item: out, - }; -};