Files
RSSHub/lib/v2/oo-software/changelog.js
Ethan Shen 57a3a3f2af feat(route): add O&O Software Changelog (#10267)
* feat(route): add O&O Software Changelog

* fix: add download link
2022-07-20 18:55:30 +08:00

41 lines
1.0 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');
module.exports = async (ctx) => {
const id = ctx.params.id ?? 'shutup10';
const rootUrl = 'https://www.oo-software.com';
const currentUrl = `${rootUrl}/en/${id}/changelog`;
const response = await got({
method: 'get',
url: currentUrl,
});
const $ = cheerio.load(response.data);
const items = $('.content h4')
.toArray()
.map((item) => {
item = $(item);
const title = item.text();
return {
title,
link: `${currentUrl}#${title.split(' ')[0]}`,
description: item.next().html(),
pubDate: parseDate(title.match(/released (on )?(.*)$/)[2], 'MMMM DD, YYYY'),
};
});
items[0].enclosure_url = $('.banner-inlay').find('a').attr('href');
ctx.state.data = {
title: $('title').text(),
link: currentUrl,
item: items,
};
};