diff --git a/docs/other.md b/docs/other.md index 9c4b3350e..03433c575 100644 --- a/docs/other.md +++ b/docs/other.md @@ -422,7 +422,7 @@ type 为 all 时,category 参数不支持 cost 和 free ### 最近更新 - + ## 爱发电 diff --git a/lib/router.js b/lib/router.js index 0da6390f4..55ecc2ad6 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3083,8 +3083,8 @@ router.get('/nasa/apod-ncku', lazyloadRouteHandler('./routes/nasa/apod-ncku')); router.get('/nasa/apod-cn', lazyloadRouteHandler('./routes/nasa/apod-cn')); // 爱Q生活网 -router.get('/iqshw/latest', lazyloadRouteHandler('./routes/3k8/latest')); -router.get('/3k8/latest', lazyloadRouteHandler('./routes/3k8/latest')); +// router.get('/iqshw/latest', lazyloadRouteHandler('./routes/3k8/latest')); +// router.get('/3k8/latest', lazyloadRouteHandler('./routes/3k8/latest')); // JustRun router.get('/justrun', lazyloadRouteHandler('./routes/justrun/index')); diff --git a/lib/routes/3k8/latest.js b/lib/v2/iqnew/latest.js similarity index 51% rename from lib/routes/3k8/latest.js rename to lib/v2/iqnew/latest.js index b08b00bc4..7627adbc7 100644 --- a/lib/routes/3k8/latest.js +++ b/lib/v2/iqnew/latest.js @@ -1,26 +1,29 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); const iconv = require('iconv-lite'); +const { parseDate } = require('@/utils/parse-date'); +const timezone = require('@/utils/timezone'); module.exports = async (ctx) => { - const rootUrl = 'https://wap.3k8.com'; + const rootUrl = 'https://www.iqnew.com'; + const url = rootUrl + '/post/new_100/'; const response = await got({ method: 'get', - url: rootUrl, + url, responseType: 'buffer', }); const $ = cheerio.load(iconv.decode(response.data, 'gb2312')); - const list = $('div.one-img-plc') - .slice(0, 10) - .map((_, item) => { + const list = $('.page-main-list .list-item a') + .slice(0, ctx.query.limit ? parseInt(ctx.query.limit) : 50) + .toArray() + .map((item) => { item = $(item); return { - link: rootUrl + item.find('a').attr('href'), + link: rootUrl + item.attr('href'), }; - }) - .get(); + }); const items = await Promise.all( list.map((item) => @@ -33,9 +36,13 @@ module.exports = async (ctx) => { const content = cheerio.load(iconv.decode(detailResponse.data, 'gb2312')); - item.title = content('h1.title').text(); - item.pubDate = new Date(content('div.news-mes span').eq(0).text().replace('发布时间:', '').trim() + ' GMT+8').toUTCString(); - item.description = content('div.news-content').html(); + item.title = content('.main-article .title').text(); + item.pubDate = timezone(parseDate(content('.time').eq(0).text()), 8); + item.description = content('.content-intro').html(); + item.author = content('.author a').text(); + item.category = content('.keyword > a') + .toArray() + .map((item) => $(item).text()); return item; }) @@ -44,7 +51,7 @@ module.exports = async (ctx) => { ctx.state.data = { title: '爱Q生活网 - 最近更新', - link: rootUrl, + link: url, item: items, }; }; diff --git a/lib/v2/iqnew/maintainer.js b/lib/v2/iqnew/maintainer.js new file mode 100644 index 000000000..14469c8ee --- /dev/null +++ b/lib/v2/iqnew/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/latest': ['nczitzk'], +}; diff --git a/lib/v2/iqnew/radar.js b/lib/v2/iqnew/radar.js new file mode 100644 index 000000000..85d8b4913 --- /dev/null +++ b/lib/v2/iqnew/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'iqnew.com': { + _name: '爱 Q 生活网', + '.': [ + { + title: '最近更新', + docs: 'https://docs.rsshub.app/others.html#ai-q-sheng-huo-wang', + source: ['/post/new_100/', '/'], + target: '/iqnew/latest', + }, + ], + }, +}; diff --git a/lib/v2/iqnew/router.js b/lib/v2/iqnew/router.js new file mode 100644 index 000000000..f70796a86 --- /dev/null +++ b/lib/v2/iqnew/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/latest', require('./latest')); +};