fix: matters item (#3929)

This commit is contained in:
hoilc
2020-02-09 19:38:52 +08:00
committed by GitHub
parent 9ce3ead6f3
commit 986aba9eba
3 changed files with 9 additions and 15 deletions

View File

@@ -6,7 +6,7 @@ module.exports = async (ctx) => {
const res = await got.get(url); const res = await got.get(url);
const $ = cheerio.load(res.data); const $ = cheerio.load(res.data);
const list = $('li section.container').get(); const list = $('section.list-item').get();
const proList = []; const proList = [];
const indexList = []; const indexList = [];
@@ -16,10 +16,8 @@ module.exports = async (ctx) => {
const $ = cheerio.load(item); const $ = cheerio.load(item);
const time = $('time').attr('datetime'); const time = $('time').attr('datetime');
const title = $('h2').text(); const title = $('h2').text();
const author = $('div.content a') const author = $('span.displayname').text();
.attr('href') const postfix = encodeURI($('section.title > a').attr('href'));
.replace(/\/@(.*?)\/.*/, '$1');
const postfix = encodeURI($('div.content a').attr('href'));
const address = `https://matters.news${postfix}`; const address = `https://matters.news${postfix}`;
const cache = await ctx.cache.get(address); const cache = await ctx.cache.get(address);
if (cache) { if (cache) {

View File

@@ -6,7 +6,7 @@ module.exports = async (ctx) => {
const res = await got.get(url); const res = await got.get(url);
const $ = cheerio.load(res.data); const $ = cheerio.load(res.data);
const list = $('article li section.container').get(); const list = $('article section.list-item').get();
const proList = []; const proList = [];
const indexList = []; const indexList = [];
@@ -16,10 +16,8 @@ module.exports = async (ctx) => {
const $ = cheerio.load(item); const $ = cheerio.load(item);
const time = $('time').attr('datetime'); const time = $('time').attr('datetime');
const title = $('h2').text(); const title = $('h2').text();
const author = $('div.content a') const author = $('span.displayname').text();
.attr('href') const partial = encodeURI($('section.title > a').attr('href'));
.replace(/\/@(.*?)\/.*/, '$1');
const partial = encodeURI($('div.content a').attr('href'));
const completeUrl = `https://matters.news${partial}`; const completeUrl = `https://matters.news${partial}`;
const cache = await ctx.cache.get(completeUrl); const cache = await ctx.cache.get(completeUrl);
if (cache) { if (cache) {

View File

@@ -6,7 +6,7 @@ module.exports = async (ctx) => {
const res = await got.get(url); const res = await got.get(url);
const $ = cheerio.load(res.data); const $ = cheerio.load(res.data);
const list = $('li section.container').get(); const list = $('section.list-item').get();
const proList = []; const proList = [];
const indexList = []; const indexList = [];
@@ -16,10 +16,8 @@ module.exports = async (ctx) => {
const $ = cheerio.load(item); const $ = cheerio.load(item);
const time = $('time').attr('datetime'); const time = $('time').attr('datetime');
const title = $('h2').text(); const title = $('h2').text();
const author = $('div.content a') const author = $('span.displayname').text();
.attr('href') const postfix = encodeURI($('section.title > a').attr('href'));
.replace(/\/@(.*?)\/.*/, '$1');
const postfix = encodeURI($('div.content a').attr('href'));
const address = `https://matters.news${postfix}`; const address = `https://matters.news${postfix}`;
const cache = await ctx.cache.get(address); const cache = await ctx.cache.get(address);
if (cache) { if (cache) {