Skip to content

Commit

Permalink
山东-乡村季风
Browse files Browse the repository at this point in the history
  • Loading branch information
iamqiz committed Oct 31, 2023
1 parent d3f822e commit 06d3b5f
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/v2/iqilu/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/xcjf': ['iamqiz'],
};
13 changes: 13 additions & 0 deletions lib/v2/iqilu/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
'iqilu.com': {
_name: '山东广播电视台',
v: [
{
title: '乡村季风',
docs: 'https://docs.rsshub.app/routes/traditional-media#shan-dong-guang-bo-dian-shi-tai',
source: '/nkpd/xcjf/index_1.html',
target: '/iqilu/xcjf',
},
],
},
};
3 changes: 3 additions & 0 deletions lib/v2/iqilu/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = (router) => {
router.get('/xcjf', require('./xiang-cun-ji-feng.js'));
};
39 changes: 39 additions & 0 deletions lib/v2/iqilu/xiang-cun-ji-feng.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
const timezone = require('@/utils/timezone');

const baseUrl = 'https://v.iqilu.com/nkpd/xcjf/index.html';
const sizeTitle = '乡村季风-山东广播电视台';

module.exports = async (ctx) => {
const response = await got(baseUrl);
const $ = cheerio.load(response.data);

// 获取当前页面的 list
const list = $('div#jmzhanshi1')
.first()
.children()
.toArray()
.map((item) => {
item = $(item);
const a = item.find('a').first();
const t = item.find(":contains('时间')").first().text();
const timeMatch = t.match(/\d+-\d+-\d+/);
const timestr = timeMatch ? timeMatch[0] : '';
return {
title: a.attr('title'),
// `link` 需要一个绝对 URL,但 `a.attr('href')` 返回一个相对 URL。
link: String(a.attr('href')),
pubDate: timestr ? timezone(parseDate(timestr, 'YYYY-MM-DD'), +8) : null,
author: '时间|' + timestr,
};
});

ctx.state.data = {
title: sizeTitle,
link: baseUrl,
description: '乡村季风-山东广播电视台',
item: list,
};
};

0 comments on commit 06d3b5f

Please sign in to comment.