@@ -849,6 +849,10 @@ GitHub 官方也提供了一些 RSS:
|
||||
|
||||
:::
|
||||
|
||||
### Sankaku Complex
|
||||
|
||||
<route name="Post" author="xyqfer" example="/sankakucomplex/post" path="/sankakucomplex/post"/>
|
||||
|
||||
## 图片
|
||||
|
||||
### 妹子图
|
||||
|
||||
@@ -738,4 +738,7 @@ router.get('/geekpark/breakingnews', require('./routes/geekpark/breakingnews'));
|
||||
// 百度
|
||||
router.get('/baidu/doodles', require('./routes/baidu/doodles'));
|
||||
|
||||
// sankakucomplex
|
||||
router.get('/sankakucomplex/post', require('./routes/sankakucomplex/post'));
|
||||
|
||||
module.exports = router;
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
const axios = require('../../utils/axios');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response = await axios({
|
||||
method: 'get',
|
||||
url: 'https://idol.sankakucomplex.com/post/atom',
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data, {
|
||||
normalizeWhitespace: true,
|
||||
xmlMode: true,
|
||||
});
|
||||
|
||||
ctx.state.data = {
|
||||
title: 'Posts | Idol Complex - Idol & Cosplay Images',
|
||||
link: 'https://idol.sankakucomplex.com/',
|
||||
item: $('entry')
|
||||
.map((index, item) => {
|
||||
item = $(item);
|
||||
|
||||
const title = item.find('title').text();
|
||||
const link = `https:${item.find('link').attr('href')}`;
|
||||
const pubDate = new Date(item.find('updated').text()).toUTCString();
|
||||
const author = item.find('author name').text();
|
||||
const summary = item.find('summary').text();
|
||||
const id = 'x-rss';
|
||||
const $2 = cheerio.load(`<div id="${id}">${item.find('content').html()}</div>`);
|
||||
|
||||
$2('a').each((index, item) => {
|
||||
item = $2(item);
|
||||
item.attr('href', `https:${item.attr('href')}`);
|
||||
});
|
||||
$2('img').each((index, item) => {
|
||||
item = $2(item);
|
||||
item.attr('src', `https:${item.attr('src')}`);
|
||||
item.attr('referrerpolicy', 'no-referrer');
|
||||
});
|
||||
|
||||
const content = $2(`#${id}`).html();
|
||||
const description = `${summary}<br>${content}`;
|
||||
|
||||
return {
|
||||
title,
|
||||
link,
|
||||
pubDate,
|
||||
author,
|
||||
description,
|
||||
};
|
||||
})
|
||||
.get(),
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user