feat(route): add 深焦 (#8627)
This commit is contained in:
@@ -2498,6 +2498,18 @@ column 为 third 时可选的 category:
|
||||
|
||||
<Route author="Jeason0228" example="/sspai/tag/apple" path="/sspai/tag/:keyword" :paramsDesc="['关键词']" radar="1"/>
|
||||
|
||||
## 深焦
|
||||
|
||||
### 分类
|
||||
|
||||
<Route author="nczitzk" example="/filmdeepfocus" path="/filmdeepfocus/:category?" :paramsDesc="['分类,见下表,默认为影评']">
|
||||
|
||||
| 影评 | 影人 | 特别策划 | 专访 | 书评 |
|
||||
| ---- | ---------- | ---------- | ---------- | ---------- |
|
||||
| page | new-page-3 | new-page-2 | new-page-4 | new-page-1 |
|
||||
|
||||
</Route>
|
||||
|
||||
## 深圳新闻网
|
||||
|
||||
### 深圳市政府新闻发布厅
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const category = ctx.params.category ?? 'page';
|
||||
|
||||
const rootUrl = 'https://www.filmdeepfocus.com';
|
||||
const currentUrl = `${rootUrl}/${category}`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
let items = $('.summary-title-link')
|
||||
.slice(0, ctx.query.limit ? parseInt(ctx.query.limit) : 20)
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
|
||||
return {
|
||||
title: item.text(),
|
||||
link: `${rootUrl}${item.attr('href')}`,
|
||||
};
|
||||
});
|
||||
|
||||
items = await Promise.all(
|
||||
items.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
content('.image-block').each(function () {
|
||||
content(this).html(`<img src="${content(this).find('img').attr('data-src')}">`);
|
||||
});
|
||||
|
||||
item.description = content('.entry-content').html();
|
||||
item.author = content('meta[itemprop="publisher"]').attr('content');
|
||||
item.pubDate = parseDate(content('meta[itemprop="datePublished"]').attr('content'));
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('title').text(),
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
'/:category?': ['nczitzk'],
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
'filmdeepfocus.com': {
|
||||
_name: '深焦',
|
||||
'.': [
|
||||
{
|
||||
title: '分类',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#shen-jiao-fen-lei',
|
||||
source: ['/:category', '/'],
|
||||
target: '/filmdeepfocus/:category?',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = function (router) {
|
||||
router.get('/:category?', require('./index'));
|
||||
};
|
||||
Reference in New Issue
Block a user