diff --git a/docs/bbs.md b/docs/bbs.md index cb7f12981..1ed898fbb 100644 --- a/docs/bbs.md +++ b/docs/bbs.md @@ -82,6 +82,12 @@ pageClass: routes +## eTOLAND + +### 主题贴 + + + ## LearnKu ### 社区 diff --git a/lib/router.js b/lib/router.js index 0fb5966d5..a86a28a35 100644 --- a/lib/router.js +++ b/lib/router.js @@ -2536,4 +2536,7 @@ router.get('/iyouport/article', require('./routes/iyouport')); // girlimg router.get('/girlimg/album/:tag?/:mode?', require('./routes/girlimg/album')); +// etoland +router.get('/etoland/:bo_table', require('./routes/etoland/board')); + module.exports = router; diff --git a/lib/routes/etoland/board.js b/lib/routes/etoland/board.js new file mode 100644 index 000000000..e9d522427 --- /dev/null +++ b/lib/routes/etoland/board.js @@ -0,0 +1,46 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const iconv = require('iconv-lite'); +const date = require('@/utils/date'); + +module.exports = async (ctx) => { + const { bo_table } = ctx.params; + + const response = await got({ + method: 'get', + url: `http://www.etoland.co.kr/bbs/board.php?bo_table=${bo_table}`, + responseType: 'buffer', + }); + + const data = iconv.decode(response.data, 'euc-kr'); + + const $ = cheerio.load(data); + const list = $('form[name="fboardlist"]>table tr[align="center"]').filter((index, item) => { + item = $(item); + return item.find('td').first().find('span.mw_basic_list_num').length > 0; + }); + + ctx.state.data = { + title: 'eTOLAND', + link: 'http://www.etoland.co.kr', + language: 'ko-KR', + description: 'eTOLAND', + item: + list && + list + .map((index, item) => { + item = $(item); + const title = item.find('td.mw_basic_list_subject a:nth-child(3) span').text(); + const description = `点赞数:${item.find('td.mw_basic_list_good').text()}
浏览数:${item.find('td.mw_basic_list_hit').text()}`; + const link = item.find('td.mw_basic_list_subject a:nth-child(3)').attr('href'); + + return { + title: title, + description: description, + link: link, + pubDate: date(item.find('td.mw_basic_list_datetime').text()), + }; + }) + .get(), + }; +};