mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 23:00:48 +08:00
@@ -994,6 +994,8 @@ GitHub 官方也提供了一些 RSS:
|
||||
|
||||
<route name="图卦" author="tgly307" example="/dapenti/tugua" path="/dapenti/tugua"/>
|
||||
|
||||
<route name="主题" author="xyqfer" example="/dapenti/subject/184" path="/dapenti/subject/:id" :paramsDesc="['主题 id']"/>
|
||||
|
||||
### Konachan Anime Wallpapers
|
||||
|
||||
::: tip 提示
|
||||
|
||||
@@ -210,6 +210,7 @@ router.get('/jandan/:sub_model', require('./routes/jandan/pic'));
|
||||
|
||||
// 喷嚏
|
||||
router.get('/dapenti/tugua', require('./routes/dapenti/tugua'));
|
||||
router.get('/dapenti/subject/:id', require('./routes/dapenti/subject'));
|
||||
|
||||
// Dockone
|
||||
router.get('/dockone/weekly', require('./routes/dockone/weekly'));
|
||||
|
||||
5
routes/dapenti/subject.js
Normal file
5
routes/dapenti/subject.js
Normal file
@@ -0,0 +1,5 @@
|
||||
const utils = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
ctx.state.data = await utils.parseFeed({ subjectid: ctx.params.id });
|
||||
};
|
||||
@@ -1,58 +1,5 @@
|
||||
const axios = require('../../utils/axios');
|
||||
const cheerio = require('cheerio');
|
||||
const iconv = require('iconv-lite');
|
||||
const utils = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const listRes = await axios({
|
||||
method: 'get',
|
||||
url: 'https://www.dapenti.com/blog/blog.asp?name=xilei&subjectid=70',
|
||||
headers: {
|
||||
Referer: 'https://www.dapenti.com/blog/blog.asp?name=xilei&subjectid=70',
|
||||
},
|
||||
// 喷嚏网编码为GBK,需要转码
|
||||
// 转码需要设定返回数据的格式,其可选项是arraybuffer,blob,document,json,text,stream
|
||||
// 默认为json
|
||||
responseType: 'arraybuffer',
|
||||
});
|
||||
// 转码
|
||||
const data = iconv.decode(listRes.data, 'gb2312');
|
||||
const $ = cheerio.load(data);
|
||||
// 只取最近的三个图卦,取全文rss
|
||||
const list = $('li', 'ul')
|
||||
.slice(0, 3)
|
||||
.get();
|
||||
|
||||
const result_item = await Promise.all(
|
||||
list.map(async (item) => {
|
||||
const el = $(item);
|
||||
const url = `https://www.dapenti.com/blog/${el.find('a').attr('href')}`;
|
||||
const original_data = await axios({
|
||||
method: 'get',
|
||||
url: url,
|
||||
headers: {
|
||||
Referer: url,
|
||||
},
|
||||
responseType: 'arraybuffer',
|
||||
});
|
||||
const convert_data = iconv.decode(original_data.data, 'gbk');
|
||||
const detail_data = cheerio
|
||||
.load(convert_data, {
|
||||
decodeEntities: false,
|
||||
})('div[class="oblog_text"]')
|
||||
.html();
|
||||
const single = {
|
||||
title: el.text(),
|
||||
description: detail_data,
|
||||
link: url,
|
||||
};
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '喷嚏图卦',
|
||||
link: 'https://www.dapenti.com/blog/blog.asp?name=xilei&subjectid=70',
|
||||
description: '喷嚏图卦',
|
||||
item: result_item,
|
||||
};
|
||||
ctx.state.data = await utils.parseFeed({ subjectid: 70 });
|
||||
};
|
||||
|
||||
60
routes/dapenti/utils.js
Normal file
60
routes/dapenti/utils.js
Normal file
@@ -0,0 +1,60 @@
|
||||
const axios = require('../../utils/axios');
|
||||
const cheerio = require('cheerio');
|
||||
const iconv = require('iconv-lite');
|
||||
|
||||
module.exports = {
|
||||
parseFeed: async ({ subjectid }) => {
|
||||
const url = `https://www.dapenti.com/blog/blog.asp?name=xilei&subjectid=${subjectid}`;
|
||||
const listRes = await axios({
|
||||
method: 'get',
|
||||
url,
|
||||
headers: {
|
||||
Referer: url,
|
||||
},
|
||||
// 喷嚏网编码为GBK,需要转码
|
||||
// 转码需要设定返回数据的格式,其可选项是arraybuffer,blob,document,json,text,stream
|
||||
// 默认为json
|
||||
responseType: 'arraybuffer',
|
||||
});
|
||||
// 转码
|
||||
const data = iconv.decode(listRes.data, 'gb2312');
|
||||
const $ = cheerio.load(data);
|
||||
// 只取最近的三个,取全文rss
|
||||
const list = $('li', 'ul')
|
||||
.slice(0, 3)
|
||||
.get();
|
||||
|
||||
const result_item = await Promise.all(
|
||||
list.map(async (item) => {
|
||||
const el = $(item);
|
||||
const url = `https://www.dapenti.com/blog/${el.find('a').attr('href')}`;
|
||||
const original_data = await axios({
|
||||
method: 'get',
|
||||
url: url,
|
||||
headers: {
|
||||
Referer: url,
|
||||
},
|
||||
responseType: 'arraybuffer',
|
||||
});
|
||||
const convert_data = iconv.decode(original_data.data, 'gbk');
|
||||
const detail_data = cheerio
|
||||
.load(convert_data, {
|
||||
decodeEntities: false,
|
||||
})('div[class="oblog_text"]')
|
||||
.html();
|
||||
const single = {
|
||||
title: el.text(),
|
||||
description: detail_data,
|
||||
link: url,
|
||||
};
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
return {
|
||||
title: `喷嚏-${subjectid}`,
|
||||
link: url,
|
||||
item: result_item,
|
||||
};
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user