RSSHub/lib/v2/3dmgame/utils.js

31 lines
1.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
const timezone = require('@/utils/timezone');
const parseArticle = (item, tryGet) =>
tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = cheerio.load(response);
if (item.link.startsWith('https://dl.3dmgame.com/')) {
const lis = $('.patchtop .lis');
const [, category, pubDate, author] = lis.text().match(/(.*?)\n.*(.*?)\n.*(.*?)\n/s);
item.description = lis.html() + $('.L_title').html() + $('.GmL_1').html();
item.category = category;
item.pubDate = timezone(parseDate(pubDate), 8);
item.author = author;
} else {
item.description = $('.news_warp_center').html();
item.pubDate = timezone(parseDate($('.time span').text()), 8);
item.author = $('.intem li:nth-child(2) .name').text().trim();
}
return item;
});
module.exports = {
parseArticle,
};