Files
RSSHub/lib/v2/gov/pbc/zcyj.js
Fatpandac 0ec2b01ec2 feat(route): add 政策研究, 工作论文 and refactor to V2 (#9324)
* feat(route): add 政策研究, 工作论文 and refactor to V2

* fix: depreciated url.resolve pubDate
2022-03-16 04:13:45 +08:00

30 lines
928 B
JavaScript

const { processItems } = require('./utils');
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
const timezone = require('@/utils/timezone');
const host = 'http://www.pbc.gov.cn';
module.exports = async (ctx) => {
const url = `${host}/redianzhuanti/118742/4122386/4122510/index.html`;
const response = await got.post(url);
const $ = cheerio.load(response.data);
const list = $('li.clearfix')
.map((_index, item) => ({
title: $(item).find('a').text(),
link: new URL($(item).find('a').attr('href'), host).href,
pubDate: timezone(parseDate($(item).find('span.fr').text(), 'YYYY-MM-DD'), +8),
}))
.get();
const items = await processItems(list, ctx);
ctx.state.data = {
title: '中国人民银行 政策研究',
link: url,
item: items,
};
};