diff --git a/docs/README.md b/docs/README.md index c2a7fbfe9..d9c776d09 100644 --- a/docs/README.md +++ b/docs/README.md @@ -849,6 +849,10 @@ GitHub 官方也提供了一些 RSS: ::: +### Sankaku Complex + + + ## 图片 ### 妹子图 diff --git a/router.js b/router.js index 5b9520d99..116448848 100644 --- a/router.js +++ b/router.js @@ -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; diff --git a/routes/sankakucomplex/post.js b/routes/sankakucomplex/post.js new file mode 100644 index 000000000..b8dd1ee1e --- /dev/null +++ b/routes/sankakucomplex/post.js @@ -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(`
${item.find('content').html()}
`); + + $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}
${content}`; + + return { + title, + link, + pubDate, + author, + description, + }; + }) + .get(), + }; +};