From fbb7fa321eb1683bf11331f2a615178e87e4b085 Mon Sep 17 00:00:00 2001 From: Chenyang Shi Date: Sun, 2 Jun 2019 12:38:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20matters=E8=A7=A3=E6=9E=90=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=20(#2272)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: matters解析失败 * 修改选择器 --- lib/routes/matters/author.js | 4 ++-- lib/routes/matters/hot.js | 4 ++-- lib/routes/matters/tags.js | 4 ++-- lib/routes/matters/topics.js | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/routes/matters/author.js b/lib/routes/matters/author.js index 7db638c548..90f29a4cc0 100644 --- a/lib/routes/matters/author.js +++ b/lib/routes/matters/author.js @@ -6,7 +6,7 @@ module.exports = async (ctx) => { const res = await axios.get(url); const $ = cheerio.load(res.data); - const list = $('section.jsx-1110843272.container').get(); + const list = $('li section.container').get(); const proList = []; const indexList = []; @@ -16,7 +16,7 @@ module.exports = async (ctx) => { const $ = cheerio.load(item); const time = $('time').attr('datetime'); const title = $('h2').text(); - const postfix = encodeURI($('a.jsx-1110843272').attr('href')); + const postfix = encodeURI($('div.content 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 e35ddfecd6..75b241a83b 100644 --- a/lib/routes/matters/hot.js +++ b/lib/routes/matters/hot.js @@ -6,7 +6,7 @@ module.exports = async (ctx) => { const res = await axios.get(url); const $ = cheerio.load(res.data); - const list = $('section.jsx-1110843272.container').get(); + const list = $('article li section.container').get(); const proList = []; const indexList = []; @@ -16,7 +16,7 @@ module.exports = async (ctx) => { const $ = cheerio.load(item); const time = $('time').attr('datetime'); const title = $('h2').text(); - const partial = encodeURI($('a.jsx-1110843272').attr('href')); + const partial = encodeURI($('div.content 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 ed138af490..f02c6191f7 100644 --- a/lib/routes/matters/tags.js +++ b/lib/routes/matters/tags.js @@ -6,7 +6,7 @@ module.exports = async (ctx) => { const res = await axios.get(url); const $ = cheerio.load(res.data); - const list = $('section.jsx-1110843272.container').get(); + const list = $('li section.container').get(); const proList = []; const indexList = []; @@ -16,7 +16,7 @@ module.exports = async (ctx) => { const $ = cheerio.load(item); const time = $('time').attr('datetime'); const title = $('h2').text(); - const postfix = encodeURI($('a.jsx-1110843272').attr('href')); + const postfix = encodeURI($('div.content a').attr('href')); const address = `https://matters.news${postfix}`; const cache = await ctx.cache.get(address); if (cache) { diff --git a/lib/routes/matters/topics.js b/lib/routes/matters/topics.js index e6946706cb..4d7183c62b 100644 --- a/lib/routes/matters/topics.js +++ b/lib/routes/matters/topics.js @@ -6,7 +6,7 @@ module.exports = async (ctx) => { const res = await axios.get(url); const $ = cheerio.load(res.data); - const list = $('section.jsx-1110843272.container').get(); + const list = $('li section.container').get(); const proList = []; const indexList = []; @@ -16,7 +16,7 @@ module.exports = async (ctx) => { const $ = cheerio.load(item); const time = $('time').attr('datetime'); const title = $('h2').text(); - const postfix = encodeURI($('a.jsx-1110843272').attr('href')); + const postfix = encodeURI($('div.content a').attr('href')); const address = `https://matters.news${postfix}`; const cache = await ctx.cache.get(address); if (cache) {