-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(route): add 河北电视台的1个节目 (#13689)
* 添加文档 * 河北电视台 ---------
- Loading branch information
Showing
5 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
'/nbszxd': ['iamqiz'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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://web.cmc.hebtv.com/cms/rmt0336/19/19js/st/ds/nmpd/nbszxd/index.shtml'; | ||
const sizeTitle = '农博士在行动-河北广播电视台'; | ||
|
||
module.exports = async (ctx) => { | ||
const response = await got(baseUrl); | ||
const $ = cheerio.load(response.data); | ||
|
||
// 获取当前页面的 list | ||
const list = $('.video_box .tv_items') | ||
.first() | ||
.children() | ||
.toArray() | ||
.map((item) => { | ||
item = $(item); | ||
const a = item.find('a').first(); | ||
const timeMatch = a.text().match(/\d+/); | ||
const timestr = timeMatch ? timeMatch[0] : ''; | ||
|
||
return { | ||
title: a.text(), | ||
// `link` 需要一个绝对 URL,但 `a.attr('href')` 返回一个相对 URL。 | ||
link: `${baseUrl}/../${a.attr('href')}`, | ||
pubDate: timestr ? timezone(parseDate(timestr, 'YYYYMMDD'), +8) : null, | ||
author: '时间|' + timestr, | ||
}; | ||
}); | ||
|
||
ctx.state.data = { | ||
title: sizeTitle, | ||
link: baseUrl, | ||
description: '农博士在行动-河北广播电视台', | ||
item: list, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module.exports = { | ||
'hebtv.com': { | ||
_name: '河北网络广播电视台', | ||
'web.cmc': [ | ||
{ | ||
title: '农博士在行动', | ||
docs: 'https://docs.rsshub.app/routes/traditional-media#he-bei-wang-luo-guang-bo-dian-shi-tai', | ||
source: '/cms/rmt0336/19/19js/st/ds/nmpd/nbszxd/index.shtml', | ||
target: '/hebtv/nbszxd', | ||
}, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = (router) => { | ||
router.get('/nbszxd', require('./nong-bo-shi-zai-xing-dong.js')); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters