From 986aba9ebaff6267560281fec22fa5713a70eb0c Mon Sep 17 00:00:00 2001 From: hoilc Date: Sun, 9 Feb 2020 19:38:52 +0800 Subject: [PATCH] fix: matters item (#3929) --- lib/routes/matters/author.js | 8 +++----- lib/routes/matters/hot.js | 8 +++----- lib/routes/matters/tags.js | 8 +++----- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/lib/routes/matters/author.js b/lib/routes/matters/author.js index cbe6fca30d..bd82503a47 100644 --- a/lib/routes/matters/author.js +++ b/lib/routes/matters/author.js @@ -6,7 +6,7 @@ module.exports = async (ctx) => { const res = await got.get(url); const $ = cheerio.load(res.data); - const list = $('li section.container').get(); + const list = $('section.list-item').get(); const proList = []; const indexList = []; @@ -16,10 +16,8 @@ module.exports = async (ctx) => { const $ = cheerio.load(item); const time = $('time').attr('datetime'); const title = $('h2').text(); - const author = $('div.content a') - .attr('href') - .replace(/\/@(.*?)\/.*/, '$1'); - const postfix = encodeURI($('div.content a').attr('href')); + const author = $('span.displayname').text(); + const postfix = encodeURI($('section.title > a').attr('href')); const address = `https://matters.news${postfix}`; const cache = await ctx.cache.get(address); if (cache) { diff --git a/lib/routes/matters/hot.js b/lib/routes/matters/hot.js index c74041f606..37eeb4bdc2 100644 --- a/lib/routes/matters/hot.js +++ b/lib/routes/matters/hot.js @@ -6,7 +6,7 @@ module.exports = async (ctx) => { const res = await got.get(url); const $ = cheerio.load(res.data); - const list = $('article li section.container').get(); + const list = $('article section.list-item').get(); const proList = []; const indexList = []; @@ -16,10 +16,8 @@ module.exports = async (ctx) => { const $ = cheerio.load(item); const time = $('time').attr('datetime'); const title = $('h2').text(); - const author = $('div.content a') - .attr('href') - .replace(/\/@(.*?)\/.*/, '$1'); - const partial = encodeURI($('div.content a').attr('href')); + const author = $('span.displayname').text(); + const partial = encodeURI($('section.title > a').attr('href')); const completeUrl = `https://matters.news${partial}`; const cache = await ctx.cache.get(completeUrl); if (cache) { diff --git a/lib/routes/matters/tags.js b/lib/routes/matters/tags.js index 08edd65f6a..b86b1cadb0 100644 --- a/lib/routes/matters/tags.js +++ b/lib/routes/matters/tags.js @@ -6,7 +6,7 @@ module.exports = async (ctx) => { const res = await got.get(url); const $ = cheerio.load(res.data); - const list = $('li section.container').get(); + const list = $('section.list-item').get(); const proList = []; const indexList = []; @@ -16,10 +16,8 @@ module.exports = async (ctx) => { const $ = cheerio.load(item); const time = $('time').attr('datetime'); const title = $('h2').text(); - const author = $('div.content a') - .attr('href') - .replace(/\/@(.*?)\/.*/, '$1'); - const postfix = encodeURI($('div.content a').attr('href')); + const author = $('span.displayname').text(); + const postfix = encodeURI($('section.title > a').attr('href')); const address = `https://matters.news${postfix}`; const cache = await ctx.cache.get(address); if (cache) {