mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-11 07:40:26 +08:00
feat: 增加好奇怪 - 好奇心日报荣誉出品 (#2252)
This commit is contained in:
@@ -486,6 +486,16 @@ pageClass: routes
|
||||
|
||||
<Route author="LogicJake" example="/vocus/user/tsetyan" path="/vocus/user/:id" :paramsDesc="['用户 id,可在用户主页的 URL 找到']"/>
|
||||
|
||||
## 好奇怪
|
||||
|
||||
### 首页
|
||||
|
||||
<Route author="HenryQW" example="/qdaily/notch/index" path="/qdaily/notch/index" />
|
||||
|
||||
### 探索
|
||||
|
||||
<Route author="HenryQW" example="/qdaily/notch/explore/1" path="/qdaily/explore/:id" :paramsDesc="['探索 id,可通过好奇怪 APP 复制分享链接找到']"/>
|
||||
|
||||
## 好奇心日报
|
||||
|
||||
### 分类
|
||||
|
||||
@@ -212,6 +212,8 @@ router.get('/jiemian/list/:cid', require('./routes/jiemian/list.js'));
|
||||
router.get('/qdaily/column/:id', require('./routes/qdaily/column'));
|
||||
router.get('/qdaily/category/:id', require('./routes/qdaily/category'));
|
||||
router.get('/qdaily/tag/:id', require('./routes/qdaily/tag'));
|
||||
router.get('/qdaily/notch/posts', require('./routes/qdaily/notch/index'));
|
||||
router.get('/qdaily/notch/explore/:id', require('./routes/qdaily/notch/explore'));
|
||||
|
||||
// 爱奇艺
|
||||
router.get('/iqiyi/dongman/:id', require('./routes/iqiyi/dongman'));
|
||||
|
||||
65
lib/routes/qdaily/notch/explore.js
Normal file
65
lib/routes/qdaily/notch/explore.js
Normal file
@@ -0,0 +1,65 @@
|
||||
const axios = require('@/utils/axios');
|
||||
|
||||
const headers = {
|
||||
'User-Agent': 'QdailyNotch/3.2.3 (iPhone; iOS 12.3.1; Scale/3.00)',
|
||||
Host: 'notch.qdaily.com',
|
||||
};
|
||||
|
||||
const ProcessFeed = async (type, item) => {
|
||||
const processPhoto = (pics) => {
|
||||
let description = '<div style="text-align: center">';
|
||||
pics.forEach((pic) => {
|
||||
description += `<img src='${pic.preview_pic}' referrerpolicy="no-referrer"> <br> <a href='${pic.original_pic.split('?imageMogr2/')[0]}'>下载原图</a> <br> <br>`;
|
||||
});
|
||||
|
||||
description += '</div>';
|
||||
return description;
|
||||
};
|
||||
|
||||
switch (type) {
|
||||
case 'lab':
|
||||
return `<div style="text-align: center"><img src='${item.index_info.index_pic}' referrerpolicy="no-referrer"> <br> ${item.post.description} <br> <a href='${item.post.share.url}'>参与讨论</a></div>`;
|
||||
case 'long_photo':
|
||||
return processPhoto(item.long_photos);
|
||||
case 'photo':
|
||||
return processPhoto(item.photos);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const meta = await axios({
|
||||
method: 'get',
|
||||
url: `http://notch.qdaily.com/api/v3/tags/${ctx.params.id}`,
|
||||
headers,
|
||||
});
|
||||
|
||||
const data = meta.data.response.tag;
|
||||
|
||||
const post = await axios({
|
||||
method: 'get',
|
||||
url: `http://notch.qdaily.com/api/v3/tags/post_index?id=${ctx.params.id}`,
|
||||
headers,
|
||||
});
|
||||
|
||||
const posts = post.data.response.feeds;
|
||||
|
||||
const items = await Promise.all(
|
||||
posts.map(async (item) => {
|
||||
const post = item.post;
|
||||
return {
|
||||
title: post.title,
|
||||
description: await ProcessFeed(data.index_type, item),
|
||||
link: post.share.url,
|
||||
pubDate: new Date(post.published_at).toUTCString(),
|
||||
author: data.title,
|
||||
};
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `好奇怪 - ${data.title}`,
|
||||
link: `http://notch.qdaily.com/`,
|
||||
description: data.description,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
56
lib/routes/qdaily/notch/index.js
Normal file
56
lib/routes/qdaily/notch/index.js
Normal file
@@ -0,0 +1,56 @@
|
||||
const axios = require('@/utils/axios');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
const headers = {
|
||||
'User-Agent': 'QdailyNotch/3.2.3 (iPhone; iOS 12.3.1; Scale/3.00)',
|
||||
Host: 'notch.qdaily.com',
|
||||
};
|
||||
|
||||
const ProcessFeed = async (id) => {
|
||||
const response = await axios({
|
||||
method: 'get',
|
||||
url: `http://notch.qdaily.com/api/v3/posts/${id}?platform=ios`,
|
||||
headers,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data.response.show_info.body);
|
||||
|
||||
const description = $('.article-detail-bd');
|
||||
|
||||
$('.article-banner > img').insertBefore(description[0].firstChild);
|
||||
|
||||
description.find('.lazyload').each((i, e) => {
|
||||
$(e).attr('src', $(e).attr('data-src'));
|
||||
});
|
||||
|
||||
return description.html();
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response = await axios({
|
||||
method: 'get',
|
||||
url: 'http://notch.qdaily.com/api/v3/posts',
|
||||
headers,
|
||||
});
|
||||
|
||||
const data = response.data.response.feeds;
|
||||
const items = await Promise.all(
|
||||
data.map(async (item) => {
|
||||
const post = item.post;
|
||||
return {
|
||||
title: post.title,
|
||||
description: await ProcessFeed(post.id),
|
||||
link: post.share.url,
|
||||
pubDate: new Date(post.published_at).toUTCString(),
|
||||
author: post.author_info ? post.author_info.username : '',
|
||||
};
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `好奇怪 - 首页`,
|
||||
link: `http://notch.qdaily.com/`,
|
||||
description: `好奇怪,开启你的脑洞世界。好奇心日报旗下产品。`,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user