From b2ace34670fe54b4e21ba2444eefdd631609decb Mon Sep 17 00:00:00 2001
From: egshuai <805394107@qq.com>
Date: Wed, 12 Apr 2023 22:45:15 +0800
Subject: [PATCH] =?UTF-8?q?fix(route):=20=E7=88=B1=20Q=20=E7=94=9F?=
=?UTF-8?q?=E6=B4=BB=E7=BD=91=20=E6=9C=80=E8=BF=91=E6=9B=B4=E6=96=B0?=
=?UTF-8?q?=E5=86=85=E5=AE=B9=E8=8E=B7=E5=8F=96=20(#12284)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* fix url and response
* refactor: migrate to v2
---------
---
docs/other.md | 2 +-
lib/router.js | 4 ++--
lib/{routes/3k8 => v2/iqnew}/latest.js | 31 ++++++++++++++++----------
lib/v2/iqnew/maintainer.js | 3 +++
lib/v2/iqnew/radar.js | 13 +++++++++++
lib/v2/iqnew/router.js | 3 +++
6 files changed, 41 insertions(+), 15 deletions(-)
rename lib/{routes/3k8 => v2/iqnew}/latest.js (51%)
create mode 100644 lib/v2/iqnew/maintainer.js
create mode 100644 lib/v2/iqnew/radar.js
create mode 100644 lib/v2/iqnew/router.js
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'));
+};