diff --git a/docs/other.md b/docs/other.md index 5bfdf13bab..95d4ca0f53 100644 --- a/docs/other.md +++ b/docs/other.md @@ -525,3 +525,21 @@ type 为 all 时,category 参数不支持 cost 和 free + +| 最新文章 | 福利社 | 求出处 | 套图集 | 门事件 | 内涵图 | 电影下载 | 影视资讯 | +| -------- | ------- | --------- | ------- | ---------- | -------- | -------------- | -------- | +| latest | fulishe | qiuchuchu | taotuji | menshijian | neihantu | dianyingxiazai | yingshi | + +| 电视剧下载 | 动漫下载 | 电影彩蛋 | 影视剧情 | 涨姿势 | 娱乐 | 明星八卦 | 音乐歌曲 | +| ---------- | -------- | -------- | -------- | ---------- | ---- | -------- | -------- | +| dianshiju | dongman | caidan | juqing | zhangzishi | yule | mingxing | music | + +| 游戏 | 电脑软件 | 实时热点 | 心灵鸡汤 | 符号大全 | 国际新闻 | 科技苑 | 其他 | +| ----- | -------- | ------------ | -------- | -------- | -------- | ------ | ----- | +| games | software | shishiredian | xljt | fhdq | xljt | tech | other | + + diff --git a/lib/router.js b/lib/router.js index 2d7829fa8c..971a033f4d 100755 --- a/lib/router.js +++ b/lib/router.js @@ -1329,4 +1329,7 @@ router.get('/asahichinese-f/:category', require('./routes/asahichinese-f/index') // 7x24小时快讯 router.get('/fx678/kx', require('./routes/fx678/kx')); +// 且听风吟福利 +router.get('/qtfyfl/:category', require('./routes/qtfyfl/category')); + module.exports = router; diff --git a/lib/routes/qtfyfl/category.js b/lib/routes/qtfyfl/category.js new file mode 100644 index 0000000000..6b55a7bace --- /dev/null +++ b/lib/routes/qtfyfl/category.js @@ -0,0 +1,101 @@ +const axios = require('../../utils/axios'); +const cheerio = require('cheerio'); + +const categoryCodes = { + latest: '最新文章', + fulishe: '福利社', + qiuchuchu: '求出处', + taotuji: '套图集', + menshijian: '门事件', + neihantu: '内涵图', + // "zngirls":"宅男女神", + dianyingxiazai: '电影下载', + yingshi: '影视资讯', + dianshiju: '电视剧下载', + dongman: '动漫下载', + caidan: '电影彩蛋', + juqing: '影视剧情', + zhangzishi: '涨姿势', + yule: '娱乐', + mingxing: '明星八卦', + music: '音乐歌曲', + games: '游戏', + software: '电脑软件', + shishiredian: '实时热点', + xljt: '心灵鸡汤', + fhdq: '符号大全', + guoji: '国际新闻', + tech: '科技苑', + other: '其他', + // "youqiubiying": "有求必应", +}; + +const host = 'http://www.qtfyfl.com'; + +module.exports = async (ctx) => { + const category = ctx.params.category; + const iTitle = categoryCodes[category]; + let link; + if (category === 'latest') { + link = host; + } else { + link = host + `/${category}`; + } + const response = await axios.get(link); + + const $ = cheerio.load(response.data); + + const list = $('article') + .slice(0, 21) + .map(function() { + const info = { + title: $(this) + .find('header') + .find('h2') + .find('a') + .attr('title'), + link: $(this) + .find('header') + .find('h2') + .find('a') + .attr('href'), + }; + return info; + }) + .get(); + + const out = await Promise.all( + list.map(async (info) => { + const title = info.title; + const itemUrl = info.link; + + const cache = await ctx.cache.get(itemUrl); + if (cache) { + return Promise.resolve(JSON.parse(cache)); + } + + const response = await axios.get(itemUrl); + + const $ = cheerio.load(response.data); + const description = $('div.txt') + .html() + .trim(); + const date = $('time').text(); + + const single = { + title: title, + link: itemUrl, + description: description, + pubDate: new Date(date).toUTCString(), + }; + ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); + return Promise.resolve(single); + }) + ); + + ctx.state.data = { + title: `${iTitle}-且听风吟福利`, + link: link, + item: out, + }; +};