From ddad8aa6426854a3573db7e98ffbac4bc1b1406b Mon Sep 17 00:00:00 2001 From: aha2mao Date: Thu, 28 Feb 2019 14:29:41 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=E4=BA=86yilia=E4=B8=BB?= =?UTF-8?q?=E9=A2=98=E7=9A=84hexo=20rss=E5=8C=96=20(#1634)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/README.md | 2 +- docs/en/README.md | 2 +- lib/routes/hexo/yilia.js | 54 ++++++++++++++-------------------------- 3 files changed, 21 insertions(+), 37 deletions(-) diff --git a/docs/README.md b/docs/README.md index 242c6ed8a..97d447182 100644 --- a/docs/README.md +++ b/docs/README.md @@ -2733,7 +2733,7 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的 - + ### Keep diff --git a/docs/en/README.md b/docs/en/README.md index d80b5ed4f..d6fa4871c 100644 --- a/docs/en/README.md +++ b/docs/en/README.md @@ -362,7 +362,7 @@ EZTV provides an official RSS feed of all torrents: https://eztv.ag/ezrss.xml - + ### Google diff --git a/lib/routes/hexo/yilia.js b/lib/routes/hexo/yilia.js index 07af62e4f..db2ddcd63 100644 --- a/lib/routes/hexo/yilia.js +++ b/lib/routes/hexo/yilia.js @@ -3,45 +3,29 @@ const axios = require('../../utils/axios'); module.exports = async (ctx) => { const url = `http://${ctx.params.url}`; - const res = await axios.get(`${url}/archives`); + const res = await axios.get(url); const data = res.data; const $ = cheerio.load(data); - const list = $('.archive-type-post'); - const item = await Promise.all( - Array.from(list).map(async (each) => { - const itemLink = $(each) - .find('.archive-article-title') - .attr('href'); - const item = { - title: $(each) - .find('.archive-article-title') - .text(), - link: encodeURI(`${url}${itemLink}`), - }; - const key = item.link; - const value = await ctx.cache.get(key); + const authorInfo = $('.left-col').find('#header'); + const title = authorInfo.find('.header-author').text(); + const subtitle = authorInfo.find('.header-subtitle').text(); + const articleNodeList = $('article'); + const articles = Array.from(articleNodeList).map((article) => { + const each = $(article); + const titleEl = each.find('.article-title'); + + return { + title: titleEl.text(), + link: encodeURI(`${url}${titleEl.attr('href')}`), + description: each.find('.article-entry').text(), + pubDate: each.find('time').attr('datetime'), + }; + }); - if (value) { - item.description = value; - } else { - const storyDeatil = await axios.get(item.link); - const data = storyDeatil.data; - const $ = cheerio.load(data); - item.pubDate = $('time').attr('datetime'); - item.description = $('.article-entry').html(); - ctx.cache.set(key, item.description, 6 * 60 * 60); - } - return Promise.resolve(item); - }) - ); ctx.state.data = { - title: $('.header-author') - .find('a') - .text(), + title, link: url, - description: $('.header-subtitle') - .eq(0) - .text(), - item, + description: subtitle, + item: articles, }; };