fix: zzz.vip 404 (#2477)
* fix: zzz.vip 404 * fix: zzz add author and pubDate
This commit is contained in:
+23
-9
@@ -1,9 +1,10 @@
|
||||
const got = require('@/utils/got');
|
||||
const parser = require('@/utils/rss-parser');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const feed = await parser.parseURL('https://z-z-z.vip/feed');
|
||||
const response = await got.get('https://z-z-z.vip');
|
||||
const $ = cheerio.load(response.data);
|
||||
const list = $('.media-list .az-article-wrapper').get();
|
||||
|
||||
const ProcessFeed = (data) => {
|
||||
const $ = cheerio.load(data);
|
||||
@@ -18,20 +19,33 @@ module.exports = async (ctx) => {
|
||||
};
|
||||
|
||||
const items = await Promise.all(
|
||||
feed.items.map(async (item) => {
|
||||
list.map(async (item) => {
|
||||
const $ = cheerio.load(item);
|
||||
const $a = $('.media-heading a');
|
||||
const link = $a.attr('href');
|
||||
|
||||
const cache = await ctx.cache.get(link);
|
||||
if (cache) {
|
||||
return Promise.resolve(JSON.parse(cache));
|
||||
}
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
url: link,
|
||||
});
|
||||
|
||||
const single = {
|
||||
guid: item.guid,
|
||||
title: item.title,
|
||||
title: $a.text(),
|
||||
description: ProcessFeed(response.data),
|
||||
pubDate: item.pubDate,
|
||||
link: item.link,
|
||||
author: item['dc:creator'],
|
||||
link: link,
|
||||
pubDate: $('.glyphicon-calendar')
|
||||
.toArray()[0]
|
||||
.nextSibling.data.replace(/年|月/g, '-')
|
||||
.replace('日', ''),
|
||||
author: $('.glyphicon-user').toArray()[0].nextSibling.data,
|
||||
};
|
||||
|
||||
ctx.cache.set(link, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user