diff --git a/docs/other.md b/docs/other.md index 4a1632a42a..7e2794e5e6 100644 --- a/docs/other.md +++ b/docs/other.md @@ -793,7 +793,7 @@ type 为 all 时,category 参数不支持 cost 和 free ### 最新辟谣 - + ## 天津产权交易中心 diff --git a/lib/router.js b/lib/router.js index 7c7ffb3ecc..e37eeb2ea8 100644 --- a/lib/router.js +++ b/lib/router.js @@ -2122,7 +2122,7 @@ router.get('/wineyun/:category', lazyloadRouteHandler('./routes/wineyun')); router.get('/kzfeed/topic/:id', lazyloadRouteHandler('./routes/kzfeed/topic')); // 腾讯新闻较真查证平台 -router.get('/factcheck', lazyloadRouteHandler('./routes/tencent/factcheck')); +// router.get('/factcheck', lazyloadRouteHandler('./routes/tencent/factcheck')); // X-MOL化学资讯平台 router.get('/x-mol/news/:tag?', lazyloadRouteHandler('./routes/x-mol/news.js')); diff --git a/lib/routes/tencent/factcheck/index.js b/lib/routes/tencent/factcheck/index.js deleted file mode 100644 index 8d4c13cbf8..0000000000 --- a/lib/routes/tencent/factcheck/index.js +++ /dev/null @@ -1,51 +0,0 @@ -const got = require('@/utils/got'); -const { parseDate } = require('@/utils/parse-date'); -const cheerio = require('cheerio'); -const CryptoJS = require('crypto-js'); - -const getRequestToken = () => { - const t = 'jzhotdata', - e = 'sgn51n6r6q97o6g3', - n = CryptoJS.DES.encrypt(Date.now().toString() + '-' + e, t).toString(); - return encodeURIComponent(n); -}; - -module.exports = async (ctx) => { - const response = await got({ - method: 'get', - url: `https://vp.fact.qq.com/loadmore?artnum=0&page=0&token=${getRequestToken()}`, - headers: { - Referer: 'https://vp.fact.qq.com/home', - }, - }); - - const data = response.data.content; - - const items = await Promise.all( - (data || []).map(async (item) => { - const link = `https://vp.fact.qq.com/article?id=${item.id}`; - const simple = { - title: `【${item.explain}】${item.title}`, - description: `${item.abstract}`, - pubDate: parseDate(item.date, 'YYYY-MM-DD'), - author: item.author, - link, - }; - - const details = await ctx.cache.tryGet(link, async () => { - const response = await got.get(link); - const $ = cheerio.load(response.data); - return { - description: `
查证要点:${$('.check_content_points').html()}
${$('.check_content_writer').html()}`, - }; - }); - return Promise.resolve(Object.assign({}, simple, details)); - }) - ); - - ctx.state.data = { - title: '较真查证平台-腾讯新闻', - link: 'https://vp.fact.qq.com/home', - item: items, - }; -}; diff --git a/lib/v2/qq/fact/index.js b/lib/v2/qq/fact/index.js new file mode 100644 index 0000000000..7b6b2a8bd7 --- /dev/null +++ b/lib/v2/qq/fact/index.js @@ -0,0 +1,61 @@ +const got = require('@/utils/got'); +const { parseDate } = require('@/utils/parse-date'); +const cheerio = require('cheerio'); +const CryptoJS = require('crypto-js'); +const { art } = require('@/utils/render'); +const path = require('path'); + +const getRequestToken = () => { + const e = 'sgn51n6r6q97o6g3'; + const t = 'jzhotdata'; + return CryptoJS.DES.encrypt(`${Date.now().toString()}-${e}`, t).toString(); +}; + +const baseUrl = 'https://vp.fact.qq.com'; + +module.exports = async (ctx) => { + const { data: response } = await got(`${baseUrl}/api/article/list`, { + headers: { + Referer: `${baseUrl}/home`, + }, + searchParams: { + page: 1, + locale: 'zh-CN', + token: getRequestToken(), + }, + }); + + const list = response.data.list.map((item) => ({ + title: `【${item.explain}】${item.title}`, + description: `
${item.abstract}`, + pubDate: parseDate(item.date, 'YYYY-MM-DD'), + author: `${item.Author.name} - ${item.Author.desc}`, + category: item.tag, + link: `${baseUrl}/article?id=${item.id}`, + })); + + const items = await Promise.all( + list.map((item) => + ctx.cache.tryGet(item.link, async () => { + const response = await got(item.link); + const $ = cheerio.load(response.data); + + const nextData = JSON.parse($('#__NEXT_DATA__').text()); + const { initialState } = nextData.props.pageProps; + + item.description = art(path.join(__dirname, '../templates/article.art'), { + data: initialState, + }); + item.pubDate = parseDate(initialState.createdAt); + + return item; + }) + ) + ); + + ctx.state.data = { + title: '较真查证平台 - 腾讯新闻', + link: `${baseUrl}/home`, + item: items, + }; +}; diff --git a/lib/v2/qq/maintainer.js b/lib/v2/qq/maintainer.js index 5c76fc5d2b..b5ef93f713 100644 --- a/lib/v2/qq/maintainer.js +++ b/lib/v2/qq/maintainer.js @@ -1,6 +1,7 @@ module.exports = { '/ac/comic/:id': ['nczitzk'], '/ac/rank/:type?/:time?': ['nczitzk'], + '/fact': ['hoilc'], '/kg/:userId': ['zhangxiang012'], '/kg/reply/:playId': ['zhangxiang012'], '/live/:id': ['nczitzk'], diff --git a/lib/v2/qq/radar.js b/lib/v2/qq/radar.js index 14f4d289b2..7eced7435b 100644 --- a/lib/v2/qq/radar.js +++ b/lib/v2/qq/radar.js @@ -37,5 +37,13 @@ module.exports = { target: (_params, url) => `/qq/kg/${new URL(url).searchParams.get('s')}`, }, ], + 'vp.fact': [ + { + title: '最新辟谣', + docs: 'https://docs.rsshub.app/other.html#teng-xun-xin-wen-jiao-zhen-cha-zheng-ping-tai', + source: ['/home', '/'], + target: '/qq/fact', + }, + ], }, }; diff --git a/lib/v2/qq/router.js b/lib/v2/qq/router.js index cdcf119fad..0d38e65656 100644 --- a/lib/v2/qq/router.js +++ b/lib/v2/qq/router.js @@ -1,6 +1,7 @@ module.exports = function (router) { router.get('/ac/comic/:id?', require('./ac/comic')); router.get('/ac/rank/:type?/:time?', require('./ac/rank')); + router.get('/fact', require('./fact')); router.get('/kg/:userId', require('./kg/user')); router.get('/kg/reply/:playId', require('./kg/reply')); router.get('/live/:id', require('./live')); diff --git a/lib/v2/qq/templates/article.art b/lib/v2/qq/templates/article.art new file mode 100644 index 0000000000..12b6f61633 --- /dev/null +++ b/lib/v2/qq/templates/article.art @@ -0,0 +1,19 @@ +{{ if data.cover }} + +{{ /if }} + +{{ if data.rumor }} +
流传说法:{{ data.rumor }}
+{{ /if }} + +{{ if data.abstract }}查证要点: +
    + {{ each data.abstract item }} +
  1. {{ item.content }}
  2. + {{ /each }} +
+{{ /if }} + +{{ if data.content }} +
{{@ data.content }}
+{{ /if }}