From 83a7846b79cc2489e694ea608e15e934e7f55651 Mon Sep 17 00:00:00 2001 From: CaoMeiYouRen <996881204@qq.com> Date: Tue, 5 Sep 2023 16:32:39 +0800 Subject: [PATCH 01/27] =?UTF-8?q?fix(route):=20=E4=BF=AE=E5=A4=8D=20?= =?UTF-8?q?=E7=B1=B3=E6=B8=B8=E7=A4=BE=20=E5=85=AC=E5=91=8A=E6=A0=8F=20tem?= =?UTF-8?q?plate=20=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/v2/mihoyo/bbs/official.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/v2/mihoyo/bbs/official.js b/lib/v2/mihoyo/bbs/official.js index 3c11e08a4a21e7..385263fc6edb60 100644 --- a/lib/v2/mihoyo/bbs/official.js +++ b/lib/v2/mihoyo/bbs/official.js @@ -19,7 +19,7 @@ const TYPE_MAP = { 3: '资讯', }; -const renderDescription = (description, images) => art(path.join(__dirname, 'templates/description.art'), { description, images }); +const renderDescription = (description, images) => art(path.join(__dirname, '../templates/description.art'), { description, images }); module.exports = async (ctx) => { const { gids, type = '2', page_size = '20', last_id = '' } = ctx.params; From 2ea08ffa69711f5fbf719dd3f55ae70896596ba3 Mon Sep 17 00:00:00 2001 From: CaoMeiYouRen <996881204@qq.com> Date: Fri, 1 Dec 2023 19:29:36 +0800 Subject: [PATCH 02/27] =?UTF-8?q?feat(route):=20=E6=96=B0=E5=A2=9E=20bing?= =?UTF-8?q?=20=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/router.js | 2 +- .../index.js => v2/bing/daily-wallpaper.js} | 0 lib/v2/bing/maintainer.js | 4 ++++ lib/v2/bing/radar.js | 22 +++++++++++++++++++ lib/v2/bing/router.js | 4 ++++ lib/v2/bing/search.js | 21 ++++++++++++++++++ website/docs/routes/other.mdx | 4 ++++ 7 files changed, 56 insertions(+), 1 deletion(-) rename lib/{routes/bing/index.js => v2/bing/daily-wallpaper.js} (100%) create mode 100644 lib/v2/bing/maintainer.js create mode 100644 lib/v2/bing/radar.js create mode 100644 lib/v2/bing/router.js create mode 100644 lib/v2/bing/search.js diff --git a/lib/router.js b/lib/router.js index 562aba65cb128f..91c106f6d84f56 100644 --- a/lib/router.js +++ b/lib/router.js @@ -946,7 +946,7 @@ router.get('/digitaling/articles/:category/:subcate', lazyloadRouteHandler('./ro router.get('/digitaling/projects/:category', lazyloadRouteHandler('./routes/digitaling/project')); // Bing壁纸 -router.get('/bing', lazyloadRouteHandler('./routes/bing/index')); +// router.get('/bing', lazyloadRouteHandler('./routes/bing/index')); // Maxjia News - DotA 2 router.get('/maxnews/dota2', lazyloadRouteHandler('./routes/maxnews/dota2')); diff --git a/lib/routes/bing/index.js b/lib/v2/bing/daily-wallpaper.js similarity index 100% rename from lib/routes/bing/index.js rename to lib/v2/bing/daily-wallpaper.js diff --git a/lib/v2/bing/maintainer.js b/lib/v2/bing/maintainer.js new file mode 100644 index 00000000000000..e20ecae190836e --- /dev/null +++ b/lib/v2/bing/maintainer.js @@ -0,0 +1,4 @@ +module.exports = { + '/': ['FHYunCai'], + '/search/:keyword': ['CaoMeiYouRen'], +}; diff --git a/lib/v2/bing/radar.js b/lib/v2/bing/radar.js new file mode 100644 index 00000000000000..5a7f5ceddafe9b --- /dev/null +++ b/lib/v2/bing/radar.js @@ -0,0 +1,22 @@ +module.exports = { + 'bing.com': { + _name: 'Bing', + cn: [ + { + title: 'Bing 每日壁纸', + docs: 'https://docs.rsshub.app/routes/picture#bing-wallpaper', + source: '/', + target: '/bing', + }, + { + title: 'Bing 搜索', + docs: 'https://docs.rsshub.app/routes/finance#bigquant-zhuan-ti-bao-gao', + source: '/', + target: (params, url) => { + const q = new URL(url).searchParams.get('q'); + return `/bing/search/${q}`; + }, + }, + ], + }, +}; diff --git a/lib/v2/bing/router.js b/lib/v2/bing/router.js new file mode 100644 index 00000000000000..da2dfe81c12495 --- /dev/null +++ b/lib/v2/bing/router.js @@ -0,0 +1,4 @@ +module.exports = function (router) { + router.get('/', require('./daily-wallpaper')); + router.get('/search/:keyword', require('./search')); +}; diff --git a/lib/v2/bing/search.js b/lib/v2/bing/search.js new file mode 100644 index 00000000000000..a3b69d0fc7762c --- /dev/null +++ b/lib/v2/bing/search.js @@ -0,0 +1,21 @@ +const parser = require('@/utils/rss-parser'); +module.exports = async (ctx) => { + const q = ctx.params.keyword; + const searchParams = new URLSearchParams({ + format: 'rss', + q, + }); + const url = new URL('https://cn.bing.com/search'); + url.search = searchParams.toString(); + const data = await parser.parseURL(url.toString()); + ctx.state.data = { + title: data.title, + link: data.link, + description: data.description + ' - ' + data.copyright, + image: data.image.url, + item: data.items.map((e) => ({ + ...e, + description: e.content, + })), + }; +}; diff --git a/website/docs/routes/other.mdx b/website/docs/routes/other.mdx index 7f9aea3143cb72..c8245f89b118cb 100644 --- a/website/docs/routes/other.mdx +++ b/website/docs/routes/other.mdx @@ -113,6 +113,10 @@ See [#app-store-mac-app-store](/routes/program-update#app-store-mac-app-store) +## Bing 搜索 + + + ## BOOKSOURCE.STORE {#booksource.store} ### 书源仓库更新 {#booksource.store-shu-yuan-cang-ku-geng-xin} From de072b33e43b3b0a100f5a618a7b5832137366ae Mon Sep 17 00:00:00 2001 From: CaoMeiYouRen <40430746+CaoMeiYouRen@users.noreply.github.com> Date: Fri, 1 Dec 2023 21:09:50 +0800 Subject: [PATCH 03/27] docs: Update other.mdx --- website/docs/routes/other.mdx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/website/docs/routes/other.mdx b/website/docs/routes/other.mdx index c8245f89b118cb..3af1a08948fa2f 100644 --- a/website/docs/routes/other.mdx +++ b/website/docs/routes/other.mdx @@ -113,7 +113,9 @@ See [#app-store-mac-app-store](/routes/program-update#app-store-mac-app-store) -## Bing 搜索 +## Bing + +### Bing 搜索 From 98aee1717515950489f4cf845d3132d9828cce63 Mon Sep 17 00:00:00 2001 From: TonyRL Date: Fri, 1 Dec 2023 14:26:16 +0000 Subject: [PATCH 04/27] docs: fix docs --- lib/v2/bing/daily-wallpaper.js | 9 ++++----- lib/v2/bing/radar.js | 8 ++++---- website/docs/routes/other.mdx | 4 ++-- website/docs/routes/picture.mdx | 4 ++-- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/lib/v2/bing/daily-wallpaper.js b/lib/v2/bing/daily-wallpaper.js index cf69bda81cac8f..2eaf345ff3ba93 100644 --- a/lib/v2/bing/daily-wallpaper.js +++ b/lib/v2/bing/daily-wallpaper.js @@ -1,22 +1,21 @@ const got = require('@/utils/got'); -const queryString = require('query-string'); module.exports = async (ctx) => { const response = await got({ method: 'get', prefixUrl: 'https://cn.bing.com', url: 'HPImageArchive.aspx', - searchParams: queryString.stringify({ + searchParams: { format: 'js', idx: 0, - n: 7, + n: ctx.query.limit ? parseInt(ctx.query.limit, 10) : 7, mkt: 'zh-CN', - }), + }, }); const data = response.data; ctx.state.data = { title: 'Bing每日壁纸', - link: `https://cn.bing.com/`, + link: 'https://cn.bing.com/', item: data.images.map((item) => ({ title: item.copyright, description: ``, diff --git a/lib/v2/bing/radar.js b/lib/v2/bing/radar.js index 5a7f5ceddafe9b..9023c3cf4ba620 100644 --- a/lib/v2/bing/radar.js +++ b/lib/v2/bing/radar.js @@ -3,14 +3,14 @@ module.exports = { _name: 'Bing', cn: [ { - title: 'Bing 每日壁纸', - docs: 'https://docs.rsshub.app/routes/picture#bing-wallpaper', + title: '每日壁纸', + docs: 'https://docs.rsshub.app/routes/picture#bing', source: '/', target: '/bing', }, { - title: 'Bing 搜索', - docs: 'https://docs.rsshub.app/routes/finance#bigquant-zhuan-ti-bao-gao', + title: '搜索', + docs: 'https://docs.rsshub.app/routes/other#bing', source: '/', target: (params, url) => { const q = new URL(url).searchParams.get('q'); diff --git a/website/docs/routes/other.mdx b/website/docs/routes/other.mdx index 3af1a08948fa2f..e18d2cdbaccca4 100644 --- a/website/docs/routes/other.mdx +++ b/website/docs/routes/other.mdx @@ -113,9 +113,9 @@ See [#app-store-mac-app-store](/routes/program-update#app-store-mac-app-store) -## Bing +## Bing {#bing} -### Bing 搜索 +### 搜索 {#bing-sou-suo} diff --git a/website/docs/routes/picture.mdx b/website/docs/routes/picture.mdx index cd24b65b386dab..b0477a913ae73d 100644 --- a/website/docs/routes/picture.mdx +++ b/website/docs/routes/picture.mdx @@ -181,9 +181,9 @@ -## Bing Wallpaper {#bing-wallpaper} +## Bing {#bing} -### Daily Wallpaper {#bing-wallpaper-daily-wallpaper} +### Daily Wallpaper {#bing-daily-wallpaper} From 13b91e19f8f91ab0cb0e19f87ff2193d036fce4e Mon Sep 17 00:00:00 2001 From: CaoMeiYouRen <996881204@qq.com> Date: Fri, 1 Dec 2023 22:29:03 +0800 Subject: [PATCH 05/27] =?UTF-8?q?feat(route):=20=E6=96=B0=E5=A2=9E=20?= =?UTF-8?q?=E7=99=BE=E5=BA=A6=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/v2/baidu/maintainer.js | 1 + lib/v2/baidu/radar.js | 11 +++++++++++ lib/v2/baidu/router.js | 1 + lib/v2/baidu/search.js | 36 +++++++++++++++++++++++++++++++++++ lib/v2/bing/radar.js | 2 +- website/docs/routes/other.mdx | 12 +++++++++--- 6 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 lib/v2/baidu/search.js diff --git a/lib/v2/baidu/maintainer.js b/lib/v2/baidu/maintainer.js index 7cbf506d1152fd..b196204cb607f9 100644 --- a/lib/v2/baidu/maintainer.js +++ b/lib/v2/baidu/maintainer.js @@ -1,5 +1,6 @@ module.exports = { '/gushitong/index': ['CaoMeiYouRen'], + '/search/:keyword': ['CaoMeiYouRen'], '/tieba/forum/good/:kw/:cid?/:sortBy?': ['u3u'], '/tieba/forum/:kw/:sortBy?': ['u3u'], '/tieba/post/:id': ['u3u'], diff --git a/lib/v2/baidu/radar.js b/lib/v2/baidu/radar.js index 20b2b9e80973e1..80ac386b2c759a 100644 --- a/lib/v2/baidu/radar.js +++ b/lib/v2/baidu/radar.js @@ -1,6 +1,17 @@ module.exports = { 'baidu.com': { _name: '百度', + www: [ + { + title: '百度搜索', + docs: 'https://docs.rsshub.app/routes/finance#bai-du-bai-du-sou-suo', + source: ['/'], + target: (params, url) => { + const keyword = new URL(url).searchParams.get('wd'); + return `/baidu/search/${keyword}`; + }, + }, + ], gushitong: [ { title: '首页指数', diff --git a/lib/v2/baidu/router.js b/lib/v2/baidu/router.js index e838568aabf9d6..3ccdbd20250b5b 100644 --- a/lib/v2/baidu/router.js +++ b/lib/v2/baidu/router.js @@ -1,5 +1,6 @@ module.exports = (router) => { router.get('/gushitong/index', require('./gushitong')); + router.get('/search/:keyword', require('./search')); router.get('/tieba/forum/good/:kw/:cid?/:sortBy?', require('./tieba/forum')); router.get('/tieba/forum/:kw/:sortBy?', require('./tieba/forum')); router.get('/tieba/post/:id', require('./tieba/post')); diff --git a/lib/v2/baidu/search.js b/lib/v2/baidu/search.js new file mode 100644 index 00000000000000..f96e6f97ba43fc --- /dev/null +++ b/lib/v2/baidu/search.js @@ -0,0 +1,36 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const { keyword } = ctx.params; + const url = `https://www.baidu.com/s?wd=${encodeURIComponent(keyword)}`; + + const response = await got(url); + const visitedLinks = new Set(); + const $ = cheerio.load(response.data); + const content_left = $('#content_left'); + const containers = content_left.find('.c-container'); + const items = containers + .map((i, el) => { + const element = $(el); + const link = element.find('h3 a').first().attr('href'); + if (link && !visitedLinks.has(link)) { + visitedLinks.add(link); + return { + title: element.find('h3').first().text(), + description: element.find('.c-gap-top-small [class^="content-right_"]').first().text() || element.find('.c-row').first().text() || element.find('.cos-row').first().text(), + link: element.find('h3 a').first().attr('href'), + author: element.find('.c-row .c-color-gray').first().text() || '', + }; + } + return null; + }) + .toArray() + .filter((e) => e && e.link); + ctx.state.data = { + title: `${keyword} - 百度搜索`, + description: `${keyword} - 百度搜索`, + link: url, + item: items, + }; +}; diff --git a/lib/v2/bing/radar.js b/lib/v2/bing/radar.js index 5a7f5ceddafe9b..e8729e61802d7f 100644 --- a/lib/v2/bing/radar.js +++ b/lib/v2/bing/radar.js @@ -10,7 +10,7 @@ module.exports = { }, { title: 'Bing 搜索', - docs: 'https://docs.rsshub.app/routes/finance#bigquant-zhuan-ti-bao-gao', + docs: 'https://docs.rsshub.app/routes/other#bing-搜索', source: '/', target: (params, url) => { const q = new URL(url).searchParams.get('q'); diff --git a/website/docs/routes/other.mdx b/website/docs/routes/other.mdx index c8245f89b118cb..ffa6c7c34fffd1 100644 --- a/website/docs/routes/other.mdx +++ b/website/docs/routes/other.mdx @@ -113,7 +113,9 @@ See [#app-store-mac-app-store](/routes/program-update#app-store-mac-app-store) -## Bing 搜索 +## Bing {#bing} + +### Bing 搜索 {#bing-bing-sou-suo} @@ -815,9 +817,13 @@ Refer to [the list of supported currencies](https://wise.com/tools/exchange-rate -## 百度热搜 {#bai-du-re-sou} +## 百度 {#bai-du} + +### 百度搜索 {#bai-du-bai-du-sou-suo} + + -### 榜单 {#bai-du-re-sou-bang-dan} +### 百度热搜榜单 {#bai-du-bai-du-re-sou-bang-dan} From dd283a25d359be412eaefb1fd7d0304ffc7e219f Mon Sep 17 00:00:00 2001 From: CaoMeiYouRen <996881204@qq.com> Date: Fri, 1 Dec 2023 23:51:10 +0800 Subject: [PATCH 06/27] =?UTF-8?q?fix(route):=20=E4=BF=AE=E5=A4=8D=20pubDat?= =?UTF-8?q?e=20=E8=A7=A3=E6=9E=90=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/v2/bing/search.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/v2/bing/search.js b/lib/v2/bing/search.js index a3b69d0fc7762c..41c021da78696d 100644 --- a/lib/v2/bing/search.js +++ b/lib/v2/bing/search.js @@ -1,4 +1,10 @@ const parser = require('@/utils/rss-parser'); +const { parseDate } = require('@/utils/parse-date'); +const dayjs = require('dayjs'); +const localizedFormat = require('dayjs/plugin/localizedFormat'); +require('dayjs/locale/zh-cn'); +dayjs.extend(localizedFormat); + module.exports = async (ctx) => { const q = ctx.params.keyword; const searchParams = new URLSearchParams({ @@ -16,6 +22,7 @@ module.exports = async (ctx) => { item: data.items.map((e) => ({ ...e, description: e.content, + pubDate: parseDate(e.pubDate, 'dddd, DD MMM YYYY HH:mm:ss [GMT]', 'zh-cn'), })), }; }; From b0b6b4de4c90eeae21d3f5b882efee6e59dba05a Mon Sep 17 00:00:00 2001 From: CaoMeiYouRen <996881204@qq.com> Date: Sat, 2 Dec 2023 00:13:20 +0800 Subject: [PATCH 07/27] =?UTF-8?q?fix(route):=20=E4=BC=98=E5=8C=96=20?= =?UTF-8?q?=E7=99=BE=E5=BA=A6=E6=90=9C=E7=B4=A2=E7=9A=84=E7=BC=93=E5=AD=98?= =?UTF-8?q?=EF=BC=8C=E5=87=8F=E8=BD=BB=E5=8F=8D=E7=88=AC=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/v2/baidu/search.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/v2/baidu/search.js b/lib/v2/baidu/search.js index f96e6f97ba43fc..d5a20105513da4 100644 --- a/lib/v2/baidu/search.js +++ b/lib/v2/baidu/search.js @@ -4,10 +4,10 @@ const cheerio = require('cheerio'); module.exports = async (ctx) => { const { keyword } = ctx.params; const url = `https://www.baidu.com/s?wd=${encodeURIComponent(keyword)}`; - - const response = await got(url); + const key = `baidu-search:${url}`; + const response = await ctx.cache.tryGet(key, async () => (await got(url)).data); const visitedLinks = new Set(); - const $ = cheerio.load(response.data); + const $ = cheerio.load(response); const content_left = $('#content_left'); const containers = content_left.find('.c-container'); const items = containers From e9afda309041b513ced49ac1707d7bbddd88c5c6 Mon Sep 17 00:00:00 2001 From: CaoMeiYouRen <996881204@qq.com> Date: Mon, 4 Dec 2023 20:22:17 +0800 Subject: [PATCH 08/27] =?UTF-8?q?feat(route):=20=E6=96=B0=E5=A2=9E=20360?= =?UTF-8?q?=20=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/v2/so/maintainer.js | 3 +++ lib/v2/so/radar.js | 16 ++++++++++++ lib/v2/so/router.js | 3 +++ lib/v2/so/search.js | 40 +++++++++++++++++++++++++++++ lib/v2/so/templates/description.art | 6 +++++ website/docs/routes/other.mdx | 6 +++++ 6 files changed, 74 insertions(+) create mode 100644 lib/v2/so/maintainer.js create mode 100644 lib/v2/so/radar.js create mode 100644 lib/v2/so/router.js create mode 100644 lib/v2/so/search.js create mode 100644 lib/v2/so/templates/description.art diff --git a/lib/v2/so/maintainer.js b/lib/v2/so/maintainer.js new file mode 100644 index 00000000000000..c9f03227a13cf8 --- /dev/null +++ b/lib/v2/so/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/search/:keyword': ['CaoMeiYouRen'], +}; diff --git a/lib/v2/so/radar.js b/lib/v2/so/radar.js new file mode 100644 index 00000000000000..db1ef431f813f3 --- /dev/null +++ b/lib/v2/so/radar.js @@ -0,0 +1,16 @@ +module.exports = { + 'so.com': { + _name: '360 搜索', + www: [ + { + title: '搜索', + docs: 'https://docs.rsshub.app/routes/other#360-sou-suo-sou-suo', + source: '/', + target: (params, url) => { + const q = new URL(url).searchParams.get('q'); + return `/so/search/${q}`; + }, + }, + ], + }, +}; diff --git a/lib/v2/so/router.js b/lib/v2/so/router.js new file mode 100644 index 00000000000000..5a0a66fe105c67 --- /dev/null +++ b/lib/v2/so/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/search/:keyword', require('./search')); +}; diff --git a/lib/v2/so/search.js b/lib/v2/so/search.js new file mode 100644 index 00000000000000..fe135fdd23db70 --- /dev/null +++ b/lib/v2/so/search.js @@ -0,0 +1,40 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { art } = require('@/utils/render'); +const path = require('path'); + +const renderDescription = (description, images) => art(path.join(__dirname, './templates/description.art'), { description, images }); + +module.exports = async (ctx) => { + const { keyword } = ctx.params; + const url = `https://www.so.com/s?q=${encodeURIComponent(keyword)}`; + const key = `360-so-search:${url}`; + const response = await ctx.cache.tryGet(key, async () => (await got(url)).data); + // const visitedLinks = new Set(); + const $ = cheerio.load(response); + const result = $('#container .result'); + const resList = result.find('.res-list'); + const items = resList + .map((i, el) => { + const element = $(el); + const imgs = element + .find('img') + .map((_j, _el) => $(_el).attr('src')) + .toArray(); + const description = element.find('.res-desc').first().text() || element.find('.mh-content-desc-info').first().text() || element.find('.res-comm-con').first().text(); + return { + link: element.find('h3 a').first().attr('href'), + title: element.find('h3').first().text(), + description: renderDescription(description, imgs), + author: element.find('.g-linkinfo cite').first().text() || '', + }; + }) + .toArray(); + // .filter((e) => e && e.link); + ctx.state.data = { + title: `${keyword} - 360 搜索`, + description: `${keyword} - 360 搜索`, + link: url, + item: items, + }; +}; diff --git a/lib/v2/so/templates/description.art b/lib/v2/so/templates/description.art new file mode 100644 index 00000000000000..5f98f4ca33ce07 --- /dev/null +++ b/lib/v2/so/templates/description.art @@ -0,0 +1,6 @@ +{{@ description }} +{{if images}} + {{each images}} + + {{/each}} +{{/if}} diff --git a/website/docs/routes/other.mdx b/website/docs/routes/other.mdx index 81daf031924e1b..38c4f54634f98a 100644 --- a/website/docs/routes/other.mdx +++ b/website/docs/routes/other.mdx @@ -1,5 +1,11 @@ # 🔍 Uncategorized +## 360 搜索 {#360-sou-suo} + +### 搜索 {#360-sou-suo-sou-suo} + + + ## 4399 论坛 {#4399-lun-tan} ### 4399 论坛 {#4399-lun-tan-4399-lun-tan} From 7abe59cc728c5a663198b36d411be082995cbcea Mon Sep 17 00:00:00 2001 From: CaoMeiYouRen <996881204@qq.com> Date: Tue, 5 Dec 2023 23:08:11 +0800 Subject: [PATCH 09/27] =?UTF-8?q?feat(route):=20=E8=BF=81=E7=A7=BB=20?= =?UTF-8?q?=E6=90=9C=E7=8B=97=E7=89=B9=E8=89=B2LOGO=20=E5=88=B0=20v2=20?= =?UTF-8?q?=E8=A7=84=E8=8C=83=EF=BC=9B=E6=B7=BB=E5=8A=A0=20=E6=90=9C?= =?UTF-8?q?=E7=8B=97=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/router.js | 2 +- lib/v2/so/search.js | 1 - lib/{routes => v2}/sogou/doodles.js | 0 lib/v2/sogou/maintainer.js | 4 +++ lib/v2/sogou/radar.js | 16 +++++++++ lib/v2/sogou/router.js | 4 +++ lib/v2/sogou/search.js | 46 ++++++++++++++++++++++++++ lib/v2/sogou/templates/description.art | 6 ++++ website/docs/routes/other.mdx | 4 +++ 9 files changed, 81 insertions(+), 2 deletions(-) rename lib/{routes => v2}/sogou/doodles.js (100%) create mode 100644 lib/v2/sogou/maintainer.js create mode 100644 lib/v2/sogou/radar.js create mode 100644 lib/v2/sogou/router.js create mode 100644 lib/v2/sogou/search.js create mode 100644 lib/v2/sogou/templates/description.art diff --git a/lib/router.js b/lib/router.js index 58d0bf1a72967d..9b0db5e4cf468a 100644 --- a/lib/router.js +++ b/lib/router.js @@ -497,7 +497,7 @@ router.get('/baidu/doodles', lazyloadRouteHandler('./routes/baidu/doodles')); router.get('/baidu/daily', lazyloadRouteHandler('./routes/baidu/daily')); // 搜狗 -router.get('/sogou/doodles', lazyloadRouteHandler('./routes/sogou/doodles')); +// router.get('/sogou/doodles', lazyloadRouteHandler('./routes/sogou/doodles')); // 香港天文台 router.get('/hko/weather', lazyloadRouteHandler('./routes/hko/weather')); diff --git a/lib/v2/so/search.js b/lib/v2/so/search.js index fe135fdd23db70..c92912a9688b0d 100644 --- a/lib/v2/so/search.js +++ b/lib/v2/so/search.js @@ -30,7 +30,6 @@ module.exports = async (ctx) => { }; }) .toArray(); - // .filter((e) => e && e.link); ctx.state.data = { title: `${keyword} - 360 搜索`, description: `${keyword} - 360 搜索`, diff --git a/lib/routes/sogou/doodles.js b/lib/v2/sogou/doodles.js similarity index 100% rename from lib/routes/sogou/doodles.js rename to lib/v2/sogou/doodles.js diff --git a/lib/v2/sogou/maintainer.js b/lib/v2/sogou/maintainer.js new file mode 100644 index 00000000000000..b94d21c1b217b7 --- /dev/null +++ b/lib/v2/sogou/maintainer.js @@ -0,0 +1,4 @@ +module.exports = { + '/doodles': ['xyqfer'], + '/search/:keyword': ['CaoMeiYouRen'], +}; diff --git a/lib/v2/sogou/radar.js b/lib/v2/sogou/radar.js new file mode 100644 index 00000000000000..01027922a30e49 --- /dev/null +++ b/lib/v2/sogou/radar.js @@ -0,0 +1,16 @@ +module.exports = { + 'sogou.com': { + _name: '搜狗搜索', + www: [ + { + title: '搜索', + docs: 'https://docs.rsshub.app/routes/other#sou-gou-sou-suo', + source: '/', + target: (params, url) => { + const keyword = new URL(url).searchParams.get('query'); + return `/sogou/search/${keyword}`; + }, + }, + ], + }, +}; diff --git a/lib/v2/sogou/router.js b/lib/v2/sogou/router.js new file mode 100644 index 00000000000000..6dbfd72eb56f15 --- /dev/null +++ b/lib/v2/sogou/router.js @@ -0,0 +1,4 @@ +module.exports = function (router) { + router.get('/doodles', require('./doodles')); + router.get('/search/:keyword', require('./search')); +}; diff --git a/lib/v2/sogou/search.js b/lib/v2/sogou/search.js new file mode 100644 index 00000000000000..dbaaee72732c4f --- /dev/null +++ b/lib/v2/sogou/search.js @@ -0,0 +1,46 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { art } = require('@/utils/render'); +const path = require('path'); +const { parseDate } = require('@/utils/parse-date'); + +const renderDescription = (description, images) => art(path.join(__dirname, './templates/description.art'), { description, images }); + +module.exports = async (ctx) => { + const { keyword } = ctx.params; + const url = `https://www.sogou.com/web?query=${encodeURIComponent(keyword)}`; + const key = `sogou-search:${url}`; + const response = await ctx.cache.tryGet(key, async () => (await got(url)).data); + const $ = cheerio.load(response); + const result = $('#main'); + const items = result + .find('.vrwrap') + .map((i, el) => { + const element = $(el); + const imgs = element + .find('img') + .map((_j, _el) => $(_el).attr('src')) + .toArray(); + const link = element.find('h3 a').first().attr('href'); + const title = element.find('h3').first().text(); + const description = element.find('.text-layout').first().text() || element.find('.space-txt').first().text() || element.find('[class^="translate"]').first().text(); + const author = element.find('.citeurl span').first().text() || ''; + const pubDate = parseDate(element.find('.citeurl .cite-date').first().text().trim()); + return { + link, + title, + description: renderDescription(description, imgs), + author, + pubDate, + }; + }) + .toArray() + .filter((e) => e.link); + + ctx.state.data = { + title: `${keyword} - 搜狗搜索`, + description: `${keyword} - 搜狗搜索`, + link: url, + item: items, + }; +}; diff --git a/lib/v2/sogou/templates/description.art b/lib/v2/sogou/templates/description.art new file mode 100644 index 00000000000000..5f98f4ca33ce07 --- /dev/null +++ b/lib/v2/sogou/templates/description.art @@ -0,0 +1,6 @@ +{{@ description }} +{{if images}} + {{each images}} + + {{/each}} +{{/if}} diff --git a/website/docs/routes/other.mdx b/website/docs/routes/other.mdx index 2f12cc0bb16933..21cf2b974acc78 100644 --- a/website/docs/routes/other.mdx +++ b/website/docs/routes/other.mdx @@ -1177,6 +1177,10 @@ Refer to [the list of supported currencies](https://wise.com/tools/exchange-rate +### 搜索 {#sou-gou-sou-suo} + + + ## 台灣事實查核中心 {#tai-wan-shi-shi-cha-he-zhong-xin} ### 最新相關資訊 / 最新查核報告 {#tai-wan-shi-shi-cha-he-zhong-xin-zui-xin-xiang-guan-zi-xun-zui-xin-cha-he-bao-gao} From 7f68ac223f5037cc24144a6ea3b6f85c716f5a93 Mon Sep 17 00:00:00 2001 From: CaoMeiYouRen <996881204@qq.com> Date: Sun, 10 Dec 2023 19:04:45 +0800 Subject: [PATCH 10/27] =?UTF-8?q?fix(route):=20=E7=99=BE=E5=BA=A6=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E5=A2=9E=E5=8A=A0=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/v2/baidu/search.js | 10 +++++++++- lib/v2/baidu/templates/description.art | 6 ++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 lib/v2/baidu/templates/description.art diff --git a/lib/v2/baidu/search.js b/lib/v2/baidu/search.js index d5a20105513da4..5259b81dcd45cd 100644 --- a/lib/v2/baidu/search.js +++ b/lib/v2/baidu/search.js @@ -1,5 +1,8 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); +const { art } = require('@/utils/render'); +const path = require('path'); +const renderDescription = (description, images) => art(path.join(__dirname, './templates/description.art'), { description, images }); module.exports = async (ctx) => { const { keyword } = ctx.params; @@ -16,9 +19,14 @@ module.exports = async (ctx) => { const link = element.find('h3 a').first().attr('href'); if (link && !visitedLinks.has(link)) { visitedLinks.add(link); + const imgs = element + .find('img') + .map((_j, _el) => $(_el).attr('src')) + .toArray(); + const description = element.find('.c-gap-top-small [class^="content-right_"]').first().text() || element.find('.c-row').first().text() || element.find('.cos-row').first().text(); return { title: element.find('h3').first().text(), - description: element.find('.c-gap-top-small [class^="content-right_"]').first().text() || element.find('.c-row').first().text() || element.find('.cos-row').first().text(), + description: renderDescription(description, imgs), link: element.find('h3 a').first().attr('href'), author: element.find('.c-row .c-color-gray').first().text() || '', }; diff --git a/lib/v2/baidu/templates/description.art b/lib/v2/baidu/templates/description.art new file mode 100644 index 00000000000000..5f98f4ca33ce07 --- /dev/null +++ b/lib/v2/baidu/templates/description.art @@ -0,0 +1,6 @@ +{{@ description }} +{{if images}} + {{each images}} + + {{/each}} +{{/if}} From 12d047761b063e6df26b896a3f31de0465bfc2c4 Mon Sep 17 00:00:00 2001 From: CaoMeiYouRen <996881204@qq.com> Date: Sun, 10 Dec 2023 20:22:47 +0800 Subject: [PATCH 11/27] =?UTF-8?q?feat(route):=20=E6=96=B0=E5=A2=9E=20Googl?= =?UTF-8?q?e=20Search?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/v2/google/maintainer.js | 1 + lib/v2/google/radar.js | 12 ++++++ lib/v2/google/router.js | 1 + lib/v2/google/search.js | 57 +++++++++++++++++++++++++ lib/v2/google/templates/description.art | 6 +++ website/docs/routes/other.mdx | 4 ++ 6 files changed, 81 insertions(+) create mode 100644 lib/v2/google/search.js create mode 100644 lib/v2/google/templates/description.art diff --git a/lib/v2/google/maintainer.js b/lib/v2/google/maintainer.js index cbdd6ddd34adeb..6abbdd362cf1fa 100644 --- a/lib/v2/google/maintainer.js +++ b/lib/v2/google/maintainer.js @@ -6,6 +6,7 @@ module.exports = { '/fonts/:sort?': ['Fatpandac'], '/news/:category/:locale': ['zoenglinghou'], '/scholar/:query': ['HenryQW'], + '/search/:keyword/:language?': ['CaoMeiYouRen'], '/sites/:id': ['hoilc'], '/sites/recentChanges/:id': ['nczitzk'], }; diff --git a/lib/v2/google/radar.js b/lib/v2/google/radar.js index 3a8cb9e1c64438..977bb99d3867df 100644 --- a/lib/v2/google/radar.js +++ b/lib/v2/google/radar.js @@ -1,6 +1,18 @@ module.exports = { 'google.com': { _name: '谷歌', + www: [ + { + title: '搜索', + docs: 'https://docs.rsshub.app/routes/other#google-alerts', + source: '/', + target: (params, url, document) => { + const q = new URL(url).searchParams.get('q'); + const lang = document.documentElement.lang; + return `/google/search/${q}/${lang}`; + }, + }, + ], chrome: [ { title: '插件更新', diff --git a/lib/v2/google/router.js b/lib/v2/google/router.js index ff5da905182d8b..0a9154d95ddc04 100644 --- a/lib/v2/google/router.js +++ b/lib/v2/google/router.js @@ -6,6 +6,7 @@ module.exports = function (router) { router.get('/fonts/:sort?', require('./fonts')); router.get('/news/:category/:locale', require('./news')); router.get('/scholar/:query', require('./scholar')); + router.get('/search/:keyword/:language?', require('./search')); router.get('/sites/recentChanges/:id', require('./sitesRecentChanges')); router.get('/sites/:id', require('./sites')); }; diff --git a/lib/v2/google/search.js b/lib/v2/google/search.js new file mode 100644 index 00000000000000..c7c6ffb19c667d --- /dev/null +++ b/lib/v2/google/search.js @@ -0,0 +1,57 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { art } = require('@/utils/render'); +const path = require('path'); + +const renderDescription = (description, images) => art(path.join(__dirname, './templates/description.art'), { description, images }); + +module.exports = async (ctx) => { + const { keyword, language } = ctx.params; + const searchParams = new URLSearchParams({ + q: keyword, + }); + const _url = new URL('https://www.google.com/search'); + _url.search = searchParams.toString(); + const url = _url.toString(); + const key = `google-search:${language}:${url}`; + const response = await ctx.cache.tryGet( + key, + async () => + ( + await got(url, { + headers: { + 'Accept-Language': language, + }, + }) + ).data + ); + const $ = cheerio.load(response); + const content = $('#rso'); + const items = content + .find('> div') + .map((i, el) => { + const element = $(el); + const link = element.find('div > div > div > div > div > span > a').first().attr('href'); + const title = element.find('div > div > div> div > div > span > a > h3').first().text(); + const imgs = element + .find('img') + .map((_j, _el) => $(_el).attr('src')) + .toArray(); + const description = element.find('div[style="-webkit-line-clamp:2"]').first().text() || element.find('div[role="heading"]').first().text(); + const author = element.find('div > div > div > div > div > span > a > div > div > span').first().text() || ''; + return { + link, + title, + description: renderDescription(description, imgs), + author, + }; + }) + .toArray() + .filter((e) => e && e.link); + ctx.state.data = { + title: `${keyword} - Google Search`, + description: `${keyword} - Google Search`, + link: url, + item: items, + }; +}; diff --git a/lib/v2/google/templates/description.art b/lib/v2/google/templates/description.art new file mode 100644 index 00000000000000..5f98f4ca33ce07 --- /dev/null +++ b/lib/v2/google/templates/description.art @@ -0,0 +1,6 @@ +{{@ description }} +{{if images}} + {{each images}} + + {{/each}} +{{/if}} diff --git a/website/docs/routes/other.mdx b/website/docs/routes/other.mdx index 21cf2b974acc78..aaa91d00e55e6d 100644 --- a/website/docs/routes/other.mdx +++ b/website/docs/routes/other.mdx @@ -251,6 +251,10 @@ Official Website: [https://news.yahoo.co.jp/pages/article/20200207](https://news +### Search {#google-search} + + + ## Grand-Challenge {#grand-challenge} ### Challenge 列表 {#grand-challenge-challenge-lie-biao} From 1185a64b7354e8a9e2eb045409d4e610e55fe47a Mon Sep 17 00:00:00 2001 From: CaoMeiYouRen <996881204@qq.com> Date: Tue, 19 Dec 2023 22:39:16 +0800 Subject: [PATCH 12/27] =?UTF-8?q?fix(route):=20=E4=BF=AE=E5=A4=8D=20?= =?UTF-8?q?=E7=99=BE=E5=BA=A6=E6=90=9C=E7=B4=A2=E7=9B=B8=E5=85=B3=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/v2/baidu/radar.js | 6 ++-- lib/v2/baidu/search.js | 65 ++++++++++++++++++++--------------- website/docs/routes/other.mdx | 10 +++--- 3 files changed, 45 insertions(+), 36 deletions(-) diff --git a/lib/v2/baidu/radar.js b/lib/v2/baidu/radar.js index 80ac386b2c759a..5d915128558427 100644 --- a/lib/v2/baidu/radar.js +++ b/lib/v2/baidu/radar.js @@ -3,8 +3,8 @@ module.exports = { _name: '百度', www: [ { - title: '百度搜索', - docs: 'https://docs.rsshub.app/routes/finance#bai-du-bai-du-sou-suo', + title: '搜索', + docs: 'https://docs.rsshub.app/routes/other#bai-du-sou-suo', source: ['/'], target: (params, url) => { const keyword = new URL(url).searchParams.get('wd'); @@ -84,7 +84,7 @@ module.exports = { top: [ { title: '热搜榜单', - docs: 'https://docs.rsshub.app/routes/other#bai-du-re-sou', + docs: 'https://docs.rsshub.app/routes/other#bai-du-re-sou-bang-dan', source: ['/board'], target: (_, url) => `/baidu/top/${new URL(url).searchParams.get('tab')}`, }, diff --git a/lib/v2/baidu/search.js b/lib/v2/baidu/search.js index 5259b81dcd45cd..d9e25741f26e84 100644 --- a/lib/v2/baidu/search.js +++ b/lib/v2/baidu/search.js @@ -3,38 +3,47 @@ const cheerio = require('cheerio'); const { art } = require('@/utils/render'); const path = require('path'); const renderDescription = (description, images) => art(path.join(__dirname, './templates/description.art'), { description, images }); - +const config = require('@/config').value; module.exports = async (ctx) => { const { keyword } = ctx.params; const url = `https://www.baidu.com/s?wd=${encodeURIComponent(keyword)}`; const key = `baidu-search:${url}`; - const response = await ctx.cache.tryGet(key, async () => (await got(url)).data); - const visitedLinks = new Set(); - const $ = cheerio.load(response); - const content_left = $('#content_left'); - const containers = content_left.find('.c-container'); - const items = containers - .map((i, el) => { - const element = $(el); - const link = element.find('h3 a').first().attr('href'); - if (link && !visitedLinks.has(link)) { - visitedLinks.add(link); - const imgs = element - .find('img') - .map((_j, _el) => $(_el).attr('src')) - .toArray(); - const description = element.find('.c-gap-top-small [class^="content-right_"]').first().text() || element.find('.c-row').first().text() || element.find('.cos-row').first().text(); - return { - title: element.find('h3').first().text(), - description: renderDescription(description, imgs), - link: element.find('h3 a').first().attr('href'), - author: element.find('.c-row .c-color-gray').first().text() || '', - }; - } - return null; - }) - .toArray() - .filter((e) => e && e.link); + + const items = await ctx.cache.tryGet( + key, + async () => { + const response = await got(url).data; + const visitedLinks = new Set(); + const $ = cheerio.load(response); + const contentLeft = $('#content_left'); + const containers = contentLeft.find('.c-container'); + return containers + .map((i, el) => { + const element = $(el); + const link = element.find('h3 a').first().attr('href'); + if (link && !visitedLinks.has(link)) { + visitedLinks.add(link); + const imgs = element + .find('img') + .map((_j, _el) => $(_el).attr('src')) + .toArray(); + const description = element.find('.c-gap-top-small [class^="content-right_"]').first().text() || element.find('.c-row').first().text() || element.find('.cos-row').first().text(); + return { + title: element.find('h3').first().text(), + description: renderDescription(description, imgs), + link: element.find('h3 a').first().attr('href'), + author: element.find('.c-row .c-color-gray').first().text() || '', + }; + } + return null; + }) + .toArray() + .filter((e) => e && e.link); + }, + config.cache.contentExpire, + false + ); + ctx.state.data = { title: `${keyword} - 百度搜索`, description: `${keyword} - 百度搜索`, diff --git a/website/docs/routes/other.mdx b/website/docs/routes/other.mdx index c5b82c899179d5..a75ad0ededf167 100644 --- a/website/docs/routes/other.mdx +++ b/website/docs/routes/other.mdx @@ -103,7 +103,7 @@ See [#app-store-mac-app-store](/routes/program-update#app-store-mac-app-store) -## BOOKSOURCE.STORE {#booksource.store} +## BOOKSOURCE.STORE {#booksource-store} ### 书源仓库更新 {#booksource-store-shu-yuan-cang-ku-geng-xin} @@ -241,7 +241,7 @@ Official Website: [https://news.yahoo.co.jp/pages/article/20200207](https://news ### Search {#google-search} - + ## Grand-Challenge {#grand-challenge} @@ -755,11 +755,11 @@ Specify options (in the format of query string) in parameter `routeParams` param ## 百度 {#bai-du} -### 百度搜索 {#bai-du-bai-du-sou-suo} +### 搜索 {#bai-du-sou-suo} - + -### 百度热搜榜单 {#bai-du-bai-du-re-sou-bang-dan} +### 热搜榜单 {#bai-du-re-sou-bang-dan} | 热搜榜 | 小说榜 | 电影榜 | 电视剧榜 | 汽车榜 | 游戏榜 | From 58c722dd3374ae4e9d81b1c6d786ff32f55a3eeb Mon Sep 17 00:00:00 2001 From: CaoMeiYouRen <996881204@qq.com> Date: Tue, 19 Dec 2023 22:41:30 +0800 Subject: [PATCH 13/27] =?UTF-8?q?fix(route):=20=E4=BF=AE=E5=A4=8D=20Google?= =?UTF-8?q?=20=E7=9B=B8=E5=85=B3=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/v2/baidu/search.js | 1 + lib/v2/google/radar.js | 2 +- lib/v2/google/search.js | 65 ++++++++++++++++++++++------------------- 3 files changed, 37 insertions(+), 31 deletions(-) diff --git a/lib/v2/baidu/search.js b/lib/v2/baidu/search.js index d9e25741f26e84..f84ab59aac3bcd 100644 --- a/lib/v2/baidu/search.js +++ b/lib/v2/baidu/search.js @@ -4,6 +4,7 @@ const { art } = require('@/utils/render'); const path = require('path'); const renderDescription = (description, images) => art(path.join(__dirname, './templates/description.art'), { description, images }); const config = require('@/config').value; + module.exports = async (ctx) => { const { keyword } = ctx.params; const url = `https://www.baidu.com/s?wd=${encodeURIComponent(keyword)}`; diff --git a/lib/v2/google/radar.js b/lib/v2/google/radar.js index 977bb99d3867df..039b0e67f5a4c8 100644 --- a/lib/v2/google/radar.js +++ b/lib/v2/google/radar.js @@ -4,7 +4,7 @@ module.exports = { www: [ { title: '搜索', - docs: 'https://docs.rsshub.app/routes/other#google-alerts', + docs: 'https://docs.rsshub.app/routes/other#google', source: '/', target: (params, url, document) => { const q = new URL(url).searchParams.get('q'); diff --git a/lib/v2/google/search.js b/lib/v2/google/search.js index c7c6ffb19c667d..61ff2ed744fcc2 100644 --- a/lib/v2/google/search.js +++ b/lib/v2/google/search.js @@ -2,6 +2,7 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); const { art } = require('@/utils/render'); const path = require('path'); +const config = require('@/config').value; const renderDescription = (description, images) => art(path.join(__dirname, './templates/description.art'), { description, images }); @@ -10,44 +11,48 @@ module.exports = async (ctx) => { const searchParams = new URLSearchParams({ q: keyword, }); - const _url = new URL('https://www.google.com/search'); - _url.search = searchParams.toString(); - const url = _url.toString(); + const tempUrl = new URL('https://www.google.com/search'); + tempUrl.search = searchParams.toString(); + const url = tempUrl.toString(); const key = `google-search:${language}:${url}`; - const response = await ctx.cache.tryGet( + const items = await ctx.cache.tryGet( key, - async () => - ( + async () => { + const response = ( await got(url, { headers: { 'Accept-Language': language, }, }) - ).data + ).data; + const $ = cheerio.load(response); + const content = $('#rso'); + return content + .find('> div') + .map((i, el) => { + const element = $(el); + const link = element.find('div > div > div > div > div > span > a').first().attr('href'); + const title = element.find('div > div > div> div > div > span > a > h3').first().text(); + const imgs = element + .find('img') + .map((_j, _el) => $(_el).attr('src')) + .toArray(); + const description = element.find('div[style="-webkit-line-clamp:2"]').first().text() || element.find('div[role="heading"]').first().text(); + const author = element.find('div > div > div > div > div > span > a > div > div > span').first().text() || ''; + return { + link, + title, + description: renderDescription(description, imgs), + author, + }; + }) + .toArray() + .filter((e) => e && e.link); + }, + config.cache.contentExpire, + false ); - const $ = cheerio.load(response); - const content = $('#rso'); - const items = content - .find('> div') - .map((i, el) => { - const element = $(el); - const link = element.find('div > div > div > div > div > span > a').first().attr('href'); - const title = element.find('div > div > div> div > div > span > a > h3').first().text(); - const imgs = element - .find('img') - .map((_j, _el) => $(_el).attr('src')) - .toArray(); - const description = element.find('div[style="-webkit-line-clamp:2"]').first().text() || element.find('div[role="heading"]').first().text(); - const author = element.find('div > div > div > div > div > span > a > div > div > span').first().text() || ''; - return { - link, - title, - description: renderDescription(description, imgs), - author, - }; - }) - .toArray() - .filter((e) => e && e.link); + ctx.state.data = { title: `${keyword} - Google Search`, description: `${keyword} - Google Search`, From 1b00eb6dce5908f691b0c2866ba60f4ff5b182db Mon Sep 17 00:00:00 2001 From: CaoMeiYouRen <996881204@qq.com> Date: Tue, 19 Dec 2023 22:55:56 +0800 Subject: [PATCH 14/27] =?UTF-8?q?fix(route):=20=E4=BF=AE=E5=A4=8D=20360=20?= =?UTF-8?q?=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/v2/so/radar.js | 2 +- lib/v2/so/search.js | 48 ++++++++++++++++++++++++++------------------- 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/lib/v2/so/radar.js b/lib/v2/so/radar.js index db1ef431f813f3..b7091505c41637 100644 --- a/lib/v2/so/radar.js +++ b/lib/v2/so/radar.js @@ -1,6 +1,6 @@ module.exports = { 'so.com': { - _name: '360 搜索', + _name: '360 公司', www: [ { title: '搜索', diff --git a/lib/v2/so/search.js b/lib/v2/so/search.js index c92912a9688b0d..f9cd12197d64c7 100644 --- a/lib/v2/so/search.js +++ b/lib/v2/so/search.js @@ -2,6 +2,7 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); const { art } = require('@/utils/render'); const path = require('path'); +const config = require('@/config').value; const renderDescription = (description, images) => art(path.join(__dirname, './templates/description.art'), { description, images }); @@ -9,27 +10,34 @@ module.exports = async (ctx) => { const { keyword } = ctx.params; const url = `https://www.so.com/s?q=${encodeURIComponent(keyword)}`; const key = `360-so-search:${url}`; - const response = await ctx.cache.tryGet(key, async () => (await got(url)).data); - // const visitedLinks = new Set(); - const $ = cheerio.load(response); - const result = $('#container .result'); - const resList = result.find('.res-list'); - const items = resList - .map((i, el) => { - const element = $(el); - const imgs = element - .find('img') - .map((_j, _el) => $(_el).attr('src')) + const items = await ctx.cache.tryGet( + key, + async () => { + const response = (await got(url)).data; + const $ = cheerio.load(response); + const result = $('#container .result'); + const resList = result.find('.res-list'); + return resList + .map((i, el) => { + const element = $(el); + const imgs = element + .find('img') + .map((j, el2) => $(el2).attr('src')) + .toArray(); + const description = element.find('.res-desc').first().text() || element.find('.mh-content-desc-info').first().text() || element.find('.res-comm-con').first().text(); + return { + link: element.find('h3 a').first().attr('href'), + title: element.find('h3').first().text(), + description: renderDescription(description, imgs), + author: element.find('.g-linkinfo cite').first().text() || '', + }; + }) .toArray(); - const description = element.find('.res-desc').first().text() || element.find('.mh-content-desc-info').first().text() || element.find('.res-comm-con').first().text(); - return { - link: element.find('h3 a').first().attr('href'), - title: element.find('h3').first().text(), - description: renderDescription(description, imgs), - author: element.find('.g-linkinfo cite').first().text() || '', - }; - }) - .toArray(); + }, + config.cache.contentExpire, + false + ); + ctx.state.data = { title: `${keyword} - 360 搜索`, description: `${keyword} - 360 搜索`, From 08dca4d76de2fa691d806c04c37551c3d8a037bc Mon Sep 17 00:00:00 2001 From: CaoMeiYouRen <996881204@qq.com> Date: Tue, 19 Dec 2023 22:59:12 +0800 Subject: [PATCH 15/27] =?UTF-8?q?fix(route):=20=E4=BF=AE=E5=A4=8D=20?= =?UTF-8?q?=E6=90=9C=E7=8B=97=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/v2/sogou/radar.js | 2 +- lib/v2/sogou/search.js | 60 ++++++++++++++++++++--------------- website/docs/routes/other.mdx | 6 ++-- 3 files changed, 38 insertions(+), 30 deletions(-) diff --git a/lib/v2/sogou/radar.js b/lib/v2/sogou/radar.js index 01027922a30e49..a548c7fad78294 100644 --- a/lib/v2/sogou/radar.js +++ b/lib/v2/sogou/radar.js @@ -1,6 +1,6 @@ module.exports = { 'sogou.com': { - _name: '搜狗搜索', + _name: '搜狗', www: [ { title: '搜索', diff --git a/lib/v2/sogou/search.js b/lib/v2/sogou/search.js index dbaaee72732c4f..7ca3df9ef1caea 100644 --- a/lib/v2/sogou/search.js +++ b/lib/v2/sogou/search.js @@ -3,6 +3,7 @@ const cheerio = require('cheerio'); const { art } = require('@/utils/render'); const path = require('path'); const { parseDate } = require('@/utils/parse-date'); +const config = require('@/config').value; const renderDescription = (description, images) => art(path.join(__dirname, './templates/description.art'), { description, images }); @@ -10,32 +11,39 @@ module.exports = async (ctx) => { const { keyword } = ctx.params; const url = `https://www.sogou.com/web?query=${encodeURIComponent(keyword)}`; const key = `sogou-search:${url}`; - const response = await ctx.cache.tryGet(key, async () => (await got(url)).data); - const $ = cheerio.load(response); - const result = $('#main'); - const items = result - .find('.vrwrap') - .map((i, el) => { - const element = $(el); - const imgs = element - .find('img') - .map((_j, _el) => $(_el).attr('src')) - .toArray(); - const link = element.find('h3 a').first().attr('href'); - const title = element.find('h3').first().text(); - const description = element.find('.text-layout').first().text() || element.find('.space-txt').first().text() || element.find('[class^="translate"]').first().text(); - const author = element.find('.citeurl span').first().text() || ''; - const pubDate = parseDate(element.find('.citeurl .cite-date').first().text().trim()); - return { - link, - title, - description: renderDescription(description, imgs), - author, - pubDate, - }; - }) - .toArray() - .filter((e) => e.link); + const items = await ctx.cache.tryGet( + key, + async () => { + const response = await got(url).data; + const $ = cheerio.load(response); + const result = $('#main'); + return result + .find('.vrwrap') + .map((i, el) => { + const element = $(el); + const imgs = element + .find('img') + .map((j, el2) => $(el2).attr('src')) + .toArray(); + const link = element.find('h3 a').first().attr('href'); + const title = element.find('h3').first().text(); + const description = element.find('.text-layout').first().text() || element.find('.space-txt').first().text() || element.find('[class^="translate"]').first().text(); + const author = element.find('.citeurl span').first().text() || ''; + const pubDate = parseDate(element.find('.citeurl .cite-date').first().text().trim()); + return { + link, + title, + description: renderDescription(description, imgs), + author, + pubDate, + }; + }) + .toArray() + .filter((e) => e.link); + }, + config.cache.contentExpire, + false + ); ctx.state.data = { title: `${keyword} - 搜狗搜索`, diff --git a/website/docs/routes/other.mdx b/website/docs/routes/other.mdx index a75ad0ededf167..8beb5c9cb04a6f 100644 --- a/website/docs/routes/other.mdx +++ b/website/docs/routes/other.mdx @@ -1,8 +1,8 @@ # 🔍 Uncategorized -## 360 搜索 {#360-sou-suo} +## 360 公司 {#360-gong-si} -### 搜索 {#360-sou-suo-sou-suo} +### 搜索 {#360-gong-si-sou-suo} @@ -1085,7 +1085,7 @@ Specify options (in the format of query string) in parameter `routeParams` param ## 搜狗 {#sou-gou} -### 搜狗特色 LOGO {#sou-gou-sou-gou-te-se-logo} +### 特色 LOGO {#sou-gou-te-se-logo} From 90b1aa7a04687947dfb8c8ce723e0ebb3c626a9a Mon Sep 17 00:00:00 2001 From: CaoMeiYouRen <996881204@qq.com> Date: Tue, 19 Dec 2023 23:16:36 +0800 Subject: [PATCH 16/27] =?UTF-8?q?fix(route):=20=E4=BF=AE=E5=A4=8D=20await?= =?UTF-8?q?=20=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/v2/baidu/search.js | 2 +- lib/v2/sogou/search.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/v2/baidu/search.js b/lib/v2/baidu/search.js index f84ab59aac3bcd..a9cf956abf0fc1 100644 --- a/lib/v2/baidu/search.js +++ b/lib/v2/baidu/search.js @@ -13,7 +13,7 @@ module.exports = async (ctx) => { const items = await ctx.cache.tryGet( key, async () => { - const response = await got(url).data; + const response = (await got(url)).data; const visitedLinks = new Set(); const $ = cheerio.load(response); const contentLeft = $('#content_left'); diff --git a/lib/v2/sogou/search.js b/lib/v2/sogou/search.js index 7ca3df9ef1caea..1d6fca4c8c1060 100644 --- a/lib/v2/sogou/search.js +++ b/lib/v2/sogou/search.js @@ -14,7 +14,7 @@ module.exports = async (ctx) => { const items = await ctx.cache.tryGet( key, async () => { - const response = await got(url).data; + const response = (await got(url)).data; const $ = cheerio.load(response); const result = $('#main'); return result From 931b7694400b2d63c840e47bf0ad669b142dc3f6 Mon Sep 17 00:00:00 2001 From: CaoMeiYouRen <996881204@qq.com> Date: Tue, 19 Dec 2023 23:28:54 +0800 Subject: [PATCH 17/27] =?UTF-8?q?fix:=20=E7=A7=BB=E9=99=A4=20google=20site?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/v2/google/router.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/v2/google/router.js b/lib/v2/google/router.js index 0a9154d95ddc04..d4e4491d0bfce2 100644 --- a/lib/v2/google/router.js +++ b/lib/v2/google/router.js @@ -8,5 +8,4 @@ module.exports = function (router) { router.get('/scholar/:query', require('./scholar')); router.get('/search/:keyword/:language?', require('./search')); router.get('/sites/recentChanges/:id', require('./sitesRecentChanges')); - router.get('/sites/:id', require('./sites')); }; From 22923a5f710238f3f06f6c2592ba11d5e1d16672 Mon Sep 17 00:00:00 2001 From: CaoMeiYouRen <996881204@qq.com> Date: Sun, 24 Dec 2023 01:42:05 +0800 Subject: [PATCH 18/27] =?UTF-8?q?fix(route):=20=E4=BF=AE=E5=A4=8D=20?= =?UTF-8?q?=E7=BC=93=E5=AD=98=E5=92=8C=E8=BF=87=E6=BB=A4=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/v2/baidu/search.js | 4 ++-- lib/v2/google/search.js | 4 ++-- lib/v2/so/search.js | 5 +++-- lib/v2/sogou/search.js | 4 ++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/v2/baidu/search.js b/lib/v2/baidu/search.js index a9cf956abf0fc1..6c8def76a57a44 100644 --- a/lib/v2/baidu/search.js +++ b/lib/v2/baidu/search.js @@ -39,9 +39,9 @@ module.exports = async (ctx) => { return null; }) .toArray() - .filter((e) => e && e.link); + .filter((e) => e?.link); }, - config.cache.contentExpire, + config.cache.routeExpire, false ); diff --git a/lib/v2/google/search.js b/lib/v2/google/search.js index 61ff2ed744fcc2..da45fb8868f105 100644 --- a/lib/v2/google/search.js +++ b/lib/v2/google/search.js @@ -47,9 +47,9 @@ module.exports = async (ctx) => { }; }) .toArray() - .filter((e) => e && e.link); + .filter((e) => e?.link); }, - config.cache.contentExpire, + config.cache.routeExpire, false ); diff --git a/lib/v2/so/search.js b/lib/v2/so/search.js index f9cd12197d64c7..bd87015e4d86b0 100644 --- a/lib/v2/so/search.js +++ b/lib/v2/so/search.js @@ -32,9 +32,10 @@ module.exports = async (ctx) => { author: element.find('.g-linkinfo cite').first().text() || '', }; }) - .toArray(); + .toArray() + .filter((e) => e?.link); }, - config.cache.contentExpire, + config.cache.routeExpire, false ); diff --git a/lib/v2/sogou/search.js b/lib/v2/sogou/search.js index 1d6fca4c8c1060..9cdb63454849fa 100644 --- a/lib/v2/sogou/search.js +++ b/lib/v2/sogou/search.js @@ -39,9 +39,9 @@ module.exports = async (ctx) => { }; }) .toArray() - .filter((e) => e.link); + .filter((e) => e?.link); }, - config.cache.contentExpire, + config.cache.routeExpire, false ); From cd5d8323e18fda55148747b920f34f12f7116d7e Mon Sep 17 00:00:00 2001 From: CaoMeiYouRen <996881204@qq.com> Date: Mon, 25 Dec 2023 14:58:35 +0800 Subject: [PATCH 19/27] =?UTF-8?q?fix(route):=20=E4=BF=AE=E5=A4=8D=20360=20?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E7=BC=BA=E5=B0=91=20cookie=20=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/v2/so/search.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/v2/so/search.js b/lib/v2/so/search.js index bd87015e4d86b0..4303293516ab13 100644 --- a/lib/v2/so/search.js +++ b/lib/v2/so/search.js @@ -9,12 +9,23 @@ const renderDescription = (description, images) => art(path.join(__dirname, './t module.exports = async (ctx) => { const { keyword } = ctx.params; const url = `https://www.so.com/s?q=${encodeURIComponent(keyword)}`; + const cookieKey = '360-so-search-cookie'; + const cookie = await ctx.cache.tryGet(cookieKey, async () => { + const response = await got('https://www.so.com/'); + const setCookie = response.headers['set-cookie']; + return setCookie?.map((e) => e.split(';')[0])?.join('; '); + }); const key = `360-so-search:${url}`; const items = await ctx.cache.tryGet( key, async () => { - const response = (await got(url)).data; - const $ = cheerio.load(response); + const response = await got(url, { + headers: { + Referer: url, + Cookie: cookie, + }, + }); + const $ = cheerio.load(response.data); const result = $('#container .result'); const resList = result.find('.res-list'); return resList @@ -27,8 +38,8 @@ module.exports = async (ctx) => { const description = element.find('.res-desc').first().text() || element.find('.mh-content-desc-info').first().text() || element.find('.res-comm-con').first().text(); return { link: element.find('h3 a').first().attr('href'), - title: element.find('h3').first().text(), - description: renderDescription(description, imgs), + title: element.find('h3').first().text().trim(), + description: renderDescription(description.trim(), imgs).trim(), author: element.find('.g-linkinfo cite').first().text() || '', }; }) From 31118c26cc10ab0eae350ed802ae8b19dc2a3ab9 Mon Sep 17 00:00:00 2001 From: CaoMeiYouRen <996881204@qq.com> Date: Mon, 25 Dec 2023 15:10:56 +0800 Subject: [PATCH 20/27] =?UTF-8?q?fix(route):=20=E4=BF=AE=E5=A4=8D=20360=20?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=20cookie=20=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/v2/so/search.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/v2/so/search.js b/lib/v2/so/search.js index 4303293516ab13..5f8e98e97c2b8b 100644 --- a/lib/v2/so/search.js +++ b/lib/v2/so/search.js @@ -11,7 +11,12 @@ module.exports = async (ctx) => { const url = `https://www.so.com/s?q=${encodeURIComponent(keyword)}`; const cookieKey = '360-so-search-cookie'; const cookie = await ctx.cache.tryGet(cookieKey, async () => { - const response = await got('https://www.so.com/'); + const response = await got('https://www.so.com/', { + headers: { + Origin: 'https://www.so.com/', + Referer: 'https://www.so.com/', + }, + }); const setCookie = response.headers['set-cookie']; return setCookie?.map((e) => e.split(';')[0])?.join('; '); }); @@ -21,6 +26,7 @@ module.exports = async (ctx) => { async () => { const response = await got(url, { headers: { + Origin: 'https://www.so.com/', Referer: url, Cookie: cookie, }, From 219f9d8da0bbeaddc1fb1b1b450794c616089e85 Mon Sep 17 00:00:00 2001 From: CaoMeiYouRen <996881204@qq.com> Date: Mon, 25 Dec 2023 15:44:08 +0800 Subject: [PATCH 21/27] =?UTF-8?q?feat(route):=20=E7=A7=BB=E9=99=A4=20so.co?= =?UTF-8?q?m=20=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/v2/so/maintainer.js | 3 -- lib/v2/so/radar.js | 16 ------- lib/v2/so/router.js | 3 -- lib/v2/so/search.js | 65 ----------------------------- lib/v2/so/templates/description.art | 6 --- website/docs/routes/other.mdx | 6 --- 6 files changed, 99 deletions(-) delete mode 100644 lib/v2/so/maintainer.js delete mode 100644 lib/v2/so/radar.js delete mode 100644 lib/v2/so/router.js delete mode 100644 lib/v2/so/search.js delete mode 100644 lib/v2/so/templates/description.art diff --git a/lib/v2/so/maintainer.js b/lib/v2/so/maintainer.js deleted file mode 100644 index c9f03227a13cf8..00000000000000 --- a/lib/v2/so/maintainer.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - '/search/:keyword': ['CaoMeiYouRen'], -}; diff --git a/lib/v2/so/radar.js b/lib/v2/so/radar.js deleted file mode 100644 index b7091505c41637..00000000000000 --- a/lib/v2/so/radar.js +++ /dev/null @@ -1,16 +0,0 @@ -module.exports = { - 'so.com': { - _name: '360 公司', - www: [ - { - title: '搜索', - docs: 'https://docs.rsshub.app/routes/other#360-sou-suo-sou-suo', - source: '/', - target: (params, url) => { - const q = new URL(url).searchParams.get('q'); - return `/so/search/${q}`; - }, - }, - ], - }, -}; diff --git a/lib/v2/so/router.js b/lib/v2/so/router.js deleted file mode 100644 index 5a0a66fe105c67..00000000000000 --- a/lib/v2/so/router.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = function (router) { - router.get('/search/:keyword', require('./search')); -}; diff --git a/lib/v2/so/search.js b/lib/v2/so/search.js deleted file mode 100644 index 5f8e98e97c2b8b..00000000000000 --- a/lib/v2/so/search.js +++ /dev/null @@ -1,65 +0,0 @@ -const got = require('@/utils/got'); -const cheerio = require('cheerio'); -const { art } = require('@/utils/render'); -const path = require('path'); -const config = require('@/config').value; - -const renderDescription = (description, images) => art(path.join(__dirname, './templates/description.art'), { description, images }); - -module.exports = async (ctx) => { - const { keyword } = ctx.params; - const url = `https://www.so.com/s?q=${encodeURIComponent(keyword)}`; - const cookieKey = '360-so-search-cookie'; - const cookie = await ctx.cache.tryGet(cookieKey, async () => { - const response = await got('https://www.so.com/', { - headers: { - Origin: 'https://www.so.com/', - Referer: 'https://www.so.com/', - }, - }); - const setCookie = response.headers['set-cookie']; - return setCookie?.map((e) => e.split(';')[0])?.join('; '); - }); - const key = `360-so-search:${url}`; - const items = await ctx.cache.tryGet( - key, - async () => { - const response = await got(url, { - headers: { - Origin: 'https://www.so.com/', - Referer: url, - Cookie: cookie, - }, - }); - const $ = cheerio.load(response.data); - const result = $('#container .result'); - const resList = result.find('.res-list'); - return resList - .map((i, el) => { - const element = $(el); - const imgs = element - .find('img') - .map((j, el2) => $(el2).attr('src')) - .toArray(); - const description = element.find('.res-desc').first().text() || element.find('.mh-content-desc-info').first().text() || element.find('.res-comm-con').first().text(); - return { - link: element.find('h3 a').first().attr('href'), - title: element.find('h3').first().text().trim(), - description: renderDescription(description.trim(), imgs).trim(), - author: element.find('.g-linkinfo cite').first().text() || '', - }; - }) - .toArray() - .filter((e) => e?.link); - }, - config.cache.routeExpire, - false - ); - - ctx.state.data = { - title: `${keyword} - 360 搜索`, - description: `${keyword} - 360 搜索`, - link: url, - item: items, - }; -}; diff --git a/lib/v2/so/templates/description.art b/lib/v2/so/templates/description.art deleted file mode 100644 index 5f98f4ca33ce07..00000000000000 --- a/lib/v2/so/templates/description.art +++ /dev/null @@ -1,6 +0,0 @@ -{{@ description }} -{{if images}} - {{each images}} - - {{/each}} -{{/if}} diff --git a/website/docs/routes/other.mdx b/website/docs/routes/other.mdx index a062c13fc256cc..a8a671f1ee10ed 100644 --- a/website/docs/routes/other.mdx +++ b/website/docs/routes/other.mdx @@ -1,11 +1,5 @@ # 🔍 Uncategorized -## 360 公司 {#360-gong-si} - -### 搜索 {#360-gong-si-sou-suo} - - - ## 4399 论坛 {#4399-lun-tan} ### 4399 论坛 {#4399-lun-tan-4399-lun-tan} From c548af5efe479d3a21c89523480fe242a9371778 Mon Sep 17 00:00:00 2001 From: TonyRL Date: Mon, 25 Dec 2023 14:44:34 +0000 Subject: [PATCH 22/27] fix: merge conflict --- website/docs/routes/other.mdx | 6 ------ 1 file changed, 6 deletions(-) diff --git a/website/docs/routes/other.mdx b/website/docs/routes/other.mdx index a8a671f1ee10ed..42aeebd6930b76 100644 --- a/website/docs/routes/other.mdx +++ b/website/docs/routes/other.mdx @@ -97,12 +97,6 @@ See [#app-store-mac-app-store](/routes/program-update#app-store-mac-app-store) -## BOOKSOURCE.STORE {#booksource-store} - -### 书源仓库更新 {#booksource-store-shu-yuan-cang-ku-geng-xin} - - - ## BOOKWALKERTW {#bookwalkertw} ### 热门新书 {#bookwalkertw-re-men-xin-shu} From cddabf81eb2761639937d4a69da302280e7b91ed Mon Sep 17 00:00:00 2001 From: CaoMeiYouRen <996881204@qq.com> Date: Wed, 17 Jan 2024 16:37:33 +0800 Subject: [PATCH 23/27] =?UTF-8?q?feat(route):=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E8=B7=AF=E7=94=B1=EF=BC=9A=E7=B1=B3=E6=B8=B8=E7=A4=BE=20-=20?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=B8=96=E5=AD=90=EF=BC=9B=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E7=B1=B3=E6=B8=B8=E7=A4=BE=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/v2/mihoyo/bbs/img-ranking.js | 4 +- lib/v2/mihoyo/bbs/official.js | 4 +- lib/v2/mihoyo/bbs/user-post.js | 54 ++++++++++++++++++++++ lib/v2/mihoyo/maintainer.js | 1 + lib/v2/mihoyo/radar.js | 78 +++++++++++++++++++------------- lib/v2/mihoyo/router.js | 1 + website/docs/routes/game.mdx | 8 +++- 7 files changed, 112 insertions(+), 38 deletions(-) create mode 100644 lib/v2/mihoyo/bbs/user-post.js diff --git a/lib/v2/mihoyo/bbs/img-ranking.js b/lib/v2/mihoyo/bbs/img-ranking.js index 92d11c8477f166..e17a0d2edcac87 100644 --- a/lib/v2/mihoyo/bbs/img-ranking.js +++ b/lib/v2/mihoyo/bbs/img-ranking.js @@ -78,7 +78,7 @@ module.exports = async (ctx) => { const items = list.map((e) => { const author = e.user.nickname; const title = e.post.subject; - const link = `https://bbs.mihoyo.com/ys/article/${e.post.post_id}`; + const link = `https://www.miyoushe.com/ys/article/${e.post.post_id}`; let describe = e.post.content || ''; try { describe = JSON.parse(e.post.content).describe; @@ -87,7 +87,7 @@ module.exports = async (ctx) => { throw error; } } - const description = renderDescription(describe || '', [e.post.cover, ...e.post.images]); + const description = renderDescription(describe || '', Array.from(new Set([e.post.cover, ...e.post.images]))); const pubDate = parseDate(e.post.created_at * 1000); return { author, diff --git a/lib/v2/mihoyo/bbs/official.js b/lib/v2/mihoyo/bbs/official.js index 385263fc6edb60..00639fd6f3f8c1 100644 --- a/lib/v2/mihoyo/bbs/official.js +++ b/lib/v2/mihoyo/bbs/official.js @@ -29,7 +29,7 @@ module.exports = async (ctx) => { page_size, last_id, }).toString(); - const url = `https://bbs-api.mihoyo.com/post/wapi/getNewsList?${query}`; + const url = `https://bbs-api.miyoushe.com/post/wapi/getNewsList?${query}`; const response = await got({ method: 'get', url, @@ -42,7 +42,7 @@ module.exports = async (ctx) => { const items = list.map((e) => { const author = e.user.nickname; const title = e.post.subject; - const link = `https://bbs.mihoyo.com/ys/article/${e.post.post_id}`; + const link = `https://www.miyoushe.com/ys/article/${e.post.post_id}`; const description = renderDescription(e.post.content, e.post.images); const pubDate = parseDate(e.post.created_at * 1000); return { diff --git a/lib/v2/mihoyo/bbs/user-post.js b/lib/v2/mihoyo/bbs/user-post.js new file mode 100644 index 00000000000000..01c54b6eb87aad --- /dev/null +++ b/lib/v2/mihoyo/bbs/user-post.js @@ -0,0 +1,54 @@ +const got = require('@/utils/got'); +const { art } = require('@/utils/render'); +const path = require('path'); +const { parseDate } = require('@/utils/parse-date'); + +const renderDescription = (description, images) => art(path.join(__dirname, '../templates/description.art'), { description, images }); + +module.exports = async (ctx) => { + const { uid, page_size: size = 20 } = ctx.params; + const query = new URLSearchParams({ + uid, + size, + }).toString(); + const url = `https://bbs-api.miyoushe.com/post/wapi/userPost?${query}`; + const response = await got({ + method: 'get', + url, + }); + const list = response?.data?.data?.list; + if (!list) { + throw new Error('未获取到数据!'); + } + const username = list[0]?.nickname; + const title = `米游社 - ${username} 的发帖`; + const items = list.map((e) => { + const author = e.user.nickname; + const title = e.post.subject; + const link = `https://www.miyoushe.com/ys/article/${e.post.post_id}`; + let describe = e.post.content || ''; + try { + describe = JSON.parse(e.post.content).describe; + } catch (error) { + if (!(error instanceof SyntaxError)) { + throw error; + } + } + const description = renderDescription(describe || '', Array.from(new Set([e.post.cover, ...e.post.images]))); + const pubDate = parseDate(e.post.created_at * 1000); + return { + author, + title, + link, + description, + pubDate, + }; + }); + + const data = { + title, + link: url, + item: items, + }; + ctx.state.data = data; +}; diff --git a/lib/v2/mihoyo/maintainer.js b/lib/v2/mihoyo/maintainer.js index d7e5821f3c438f..4cbbd2678efc79 100644 --- a/lib/v2/mihoyo/maintainer.js +++ b/lib/v2/mihoyo/maintainer.js @@ -1,6 +1,7 @@ module.exports = { '/bbs/img-ranking/:game/:routeParams?': ['CaoMeiYouRen'], '/bbs/official/:gids/:type?/:page_size?/:last_id?': ['CaoMeiYouRen'], + '/bbs/user-post/:uid/:page_size?': ['CaoMeiYouRen'], '/sr/:location?/:category?': ['shinanory'], '/ys/:location?/:category?': ['nczitzk'], }; diff --git a/lib/v2/mihoyo/radar.js b/lib/v2/mihoyo/radar.js index e7a61d00aa725d..78f65c799dcb39 100644 --- a/lib/v2/mihoyo/radar.js +++ b/lib/v2/mihoyo/radar.js @@ -1,3 +1,44 @@ +const bbs = [ + { + title: '米游社 - 同人榜', + docs: 'https://docs.rsshub.app/routes/game#mi-ha-you', + source: '/:game/imgRanking/:forum_id/:ranking_id/:cate_id', + target: `/mihoyo/bbs/img-ranking/:game`, + }, + { + title: '米游社 - 官方公告', + docs: 'https://docs.rsshub.app/routes/game#mi-ha-you', + source: ['/:game/home/28', '/:game/home/6', '/:game/home/31', '/:game/home/33', '/:game/home/53', '/:game/home/58'], + target: (params, url) => { + const GITS_MAP = { + bh3: 1, // '崩坏三', + ys: 2, // '原神', + bh2: 3, // '崩坏二', + wd: 4, // '未定事件簿', + sr: 6, // '崩坏:星穹铁道', + zzz: 8, // '绝区零' + }; + const { game } = params; + const gids = GITS_MAP[game]; + if (!gids) { + return ''; + } + const type = new URL(url).searchParams.get('type') || '1'; + const page_size = '20'; + const last_id = ''; + return `/mihoyo/bbs/official/${gids}/${type}/${page_size}/${last_id}`; + }, + }, + { + title: '米游社 - 用户帖子', + docs: 'https://docs.rsshub.app/routes/game#mi-ha-you', + source: '/:game/accountCenter/postList', + target: (params, url) => { + const uid = new URL(url).searchParams.get('id'); + return `/mihoyo/bbs/user-post/${uid}`; + }, + }, +]; module.exports = { 'hoyoverse.com': { _name: '米哈游', @@ -20,38 +61,7 @@ module.exports = { }, 'mihoyo.com': { _name: '米哈游', - bbs: [ - { - title: '米游社 - 同人榜', - docs: 'https://docs.rsshub.app/routes/game#mi-ha-you', - source: '/:game/imgRanking/:forum_id/:ranking_id/:cate_id', - target: `/mihoyo/bbs/img-ranking/:game`, - }, - { - title: '米游社 - 官方公告', - docs: 'https://docs.rsshub.app/routes/game#mi-ha-you', - source: ['/:game/home/28', '/:game/home/6', '/:game/home/31', '/:game/home/33', '/:game/home/53', '/:game/home/58'], - target: (params, url) => { - const GITS_MAP = { - bh3: 1, // '崩坏三', - ys: 2, // '原神', - bh2: 3, // '崩坏二', - wd: 4, // '未定事件簿', - sr: 6, // '崩坏:星穹铁道', - zzz: 8, // '绝区零' - }; - const { game } = params; - const gids = GITS_MAP[game]; - if (!gids) { - return ''; - } - const type = new URL(url).searchParams.get('type') || '1'; - const page_size = '20'; - const last_id = ''; - return `/mihoyo/bbs/official/${gids}/${type}/${page_size}/${last_id}`; - }, - }, - ], + bbs, sr: [ { title: '崩坏:星穹铁道 - 新闻', @@ -69,4 +79,8 @@ module.exports = { }, ], }, + 'miyoushe.com': { + _name: '米游社', + '.': bbs, + }, }; diff --git a/lib/v2/mihoyo/router.js b/lib/v2/mihoyo/router.js index d9cdb704ad3ec5..97e86c37764731 100644 --- a/lib/v2/mihoyo/router.js +++ b/lib/v2/mihoyo/router.js @@ -1,6 +1,7 @@ module.exports = function (router) { router.get('/bbs/img-ranking/:game/:routeParams?', require('./bbs/img-ranking')); router.get('/bbs/official/:gids/:type?/:page_size?/:last_id?', require('./bbs/official')); + router.get('/bbs/user-post/:uid/:page_size?', require('./bbs/user-post')); router.get('/sr/:location?/:category?', require('./sr/news')); router.get('/ys/:location?/:category?', require('./ys/news')); }; diff --git a/website/docs/routes/game.mdx b/website/docs/routes/game.mdx index 17192d6eab76b7..d36048cfc2e1dc 100644 --- a/website/docs/routes/game.mdx +++ b/website/docs/routes/game.mdx @@ -658,7 +658,7 @@ Example:`https://www.iyingdi.com/tz/people/55547` ,id 是 `55547` ### 米游社 - 同人榜 {#mi-ha-you-mi-you-she-tong-ren-bang} - + | 键 | 含义 | 接受的值 | 默认值 | | ----------- | ------------------------------------- | -------------------------------------------------------------------- | ------------ | | forumType | 主榜类型(仅原神、大别野有 cos 主榜) | tongren/cos | tongren | @@ -701,7 +701,7 @@ Example:`https://www.iyingdi.com/tz/people/55547` ,id 是 `55547` ### 米游社 - 官方公告 {#mi-ha-you-mi-you-she-guan-fang-gong-gao} - + 游戏 id | 崩坏三 | 原神 | 崩坏二 | 未定事件簿 | 星穹铁道 | 绝区零 | @@ -715,6 +715,10 @@ Example:`https://www.iyingdi.com/tz/people/55547` ,id 是 `55547` | 1 | 2 | 3 | +### 米游社 - 用户帖子 {#mi-ha-you-mi-you-she-yong-hu-tie-zi} + + + ### 原神 {#mi-ha-you-yuan-shen} #### 新闻 {#mi-ha-you-yuan-shen-xin-wen} From 49aa86678fd28c91bc2d74cd267ecd80405e48e3 Mon Sep 17 00:00:00 2001 From: CaoMeiYouRen <996881204@qq.com> Date: Wed, 17 Jan 2024 16:47:38 +0800 Subject: [PATCH 24/27] =?UTF-8?q?fix(route):=20=E4=BF=AE=E5=A4=8D=20?= =?UTF-8?q?=E7=B1=B3=E6=B8=B8=E7=A4=BE=E7=94=A8=E6=88=B7=E5=B8=96=E5=AD=90?= =?UTF-8?q?=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/v2/mihoyo/bbs/user-post.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/v2/mihoyo/bbs/user-post.js b/lib/v2/mihoyo/bbs/user-post.js index 01c54b6eb87aad..7eb822ed6714e8 100644 --- a/lib/v2/mihoyo/bbs/user-post.js +++ b/lib/v2/mihoyo/bbs/user-post.js @@ -20,7 +20,7 @@ module.exports = async (ctx) => { if (!list) { throw new Error('未获取到数据!'); } - const username = list[0]?.nickname; + const username = list[0]?.user.nickname; const title = `米游社 - ${username} 的发帖`; const items = list.map((e) => { const author = e.user.nickname; From 3123b9a906dc49d6a0b8ce7abd67d57d97b19faa Mon Sep 17 00:00:00 2001 From: CaoMeiYouRen <996881204@qq.com> Date: Wed, 17 Jan 2024 23:42:59 +0800 Subject: [PATCH 25/27] =?UTF-8?q?feat(route):=20=E6=96=B0=E5=A2=9E=20?= =?UTF-8?q?=E7=B1=B3=E6=B8=B8=E7=A4=BE=20=E7=94=A8=E6=88=B7=E5=85=B3?= =?UTF-8?q?=E6=B3=A8=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/v2/mihoyo/bbs/cache.js | 33 +++++++++++++++++++++ lib/v2/mihoyo/bbs/follow-list.js | 49 ++++++++++++++++++++++++++++++++ lib/v2/mihoyo/bbs/user-post.js | 6 ++-- lib/v2/mihoyo/maintainer.js | 3 +- lib/v2/mihoyo/radar.js | 9 ++++++ lib/v2/mihoyo/router.js | 3 +- website/docs/routes/game.mdx | 6 +++- 7 files changed, 104 insertions(+), 5 deletions(-) create mode 100644 lib/v2/mihoyo/bbs/cache.js create mode 100644 lib/v2/mihoyo/bbs/follow-list.js diff --git a/lib/v2/mihoyo/bbs/cache.js b/lib/v2/mihoyo/bbs/cache.js new file mode 100644 index 00000000000000..1d400008478748 --- /dev/null +++ b/lib/v2/mihoyo/bbs/cache.js @@ -0,0 +1,33 @@ +const got = require('@/utils/got'); + +module.exports = { + getUserFullInfo: (ctx, uid) => { + const key = 'mihoyo:user-full-info-uid-' + uid; + return ctx.cache.tryGet(key, async () => { + const query = new URLSearchParams({ + uid, + gids: 2, + }).toString(); + const url = `https://bbs-api.miyoushe.com/user/wapi/getUserFullInfo?${query}`; + const response = await got({ + method: 'get', + url, + headers: { + Referer: `https://www.miyoushe.com/ys/accountCenter/postList?id=${uid}`, + }, + }); + const userInfo = response?.data?.data?.user_info; + if (!userInfo) { + throw new Error('未获取到数据!'); + } + const { nickname, introduce, gender, certification, avatar_url } = userInfo; + return { + nickname, + introduce, + gender, + certification, + avatar_url, + }; + }); + }, +}; diff --git a/lib/v2/mihoyo/bbs/follow-list.js b/lib/v2/mihoyo/bbs/follow-list.js new file mode 100644 index 00000000000000..7bd5951abbb488 --- /dev/null +++ b/lib/v2/mihoyo/bbs/follow-list.js @@ -0,0 +1,49 @@ +const got = require('@/utils/got'); +const { art } = require('@/utils/render'); +const path = require('path'); +const cache = require('./cache'); + +const renderDescription = (description, images) => art(path.join(__dirname, '../templates/description.art'), { description, images }); + +module.exports = async (ctx) => { + const { uid } = ctx.params; + const page_size = ctx.query.limit || '20'; + const query = new URLSearchParams({ + gids: 2, + uid, + page_size, + }).toString(); + const link = `https://www.miyoushe.com/ys/accountCenter/followList?id=${uid}`; + const url = `https://bbs-api.miyoushe.com/user/wapi/following?${query}`; + const response = await got({ + method: 'get', + url, + headers: { + Origin: 'https://www.miyoushe.com', + Referer: link, + }, + }); + const list = response?.data?.data?.result; + if (!list) { + throw new Error('未获取到数据!'); + } + const { nickname: username } = await cache.getUserFullInfo(ctx, uid); + const title = `米游社 - ${username} 的关注`; + const items = list.map((e) => { + const title = e.user.nickname; + const link = `https://www.miyoushe.com/ys/accountCenter/postList?id=${e.user.uid}`; + const description = renderDescription(`${e.user.certification.label || ''}\n${e.user.introduce || ''}`.trim(), [e.user.avatar_url]); + return { + title, + link, + description, + }; + }); + + const data = { + title, + link, + item: items, + }; + ctx.state.data = data; +}; diff --git a/lib/v2/mihoyo/bbs/user-post.js b/lib/v2/mihoyo/bbs/user-post.js index 7eb822ed6714e8..c1a213c0e6440a 100644 --- a/lib/v2/mihoyo/bbs/user-post.js +++ b/lib/v2/mihoyo/bbs/user-post.js @@ -6,11 +6,13 @@ const { parseDate } = require('@/utils/parse-date'); const renderDescription = (description, images) => art(path.join(__dirname, '../templates/description.art'), { description, images }); module.exports = async (ctx) => { - const { uid, page_size: size = 20 } = ctx.params; + const { uid } = ctx.params; + const size = ctx.query.limit || '20'; const query = new URLSearchParams({ uid, size, }).toString(); + const link = `https://www.miyoushe.com/ys/accountCenter/postList?id=${uid}`; const url = `https://bbs-api.miyoushe.com/post/wapi/userPost?${query}`; const response = await got({ method: 'get', @@ -47,7 +49,7 @@ module.exports = async (ctx) => { const data = { title, - link: url, + link, item: items, }; ctx.state.data = data; diff --git a/lib/v2/mihoyo/maintainer.js b/lib/v2/mihoyo/maintainer.js index 4cbbd2678efc79..7eb64e1a81e80a 100644 --- a/lib/v2/mihoyo/maintainer.js +++ b/lib/v2/mihoyo/maintainer.js @@ -1,7 +1,8 @@ module.exports = { + '/bbs/follow-list/:uid': ['CaoMeiYouRen'], '/bbs/img-ranking/:game/:routeParams?': ['CaoMeiYouRen'], '/bbs/official/:gids/:type?/:page_size?/:last_id?': ['CaoMeiYouRen'], - '/bbs/user-post/:uid/:page_size?': ['CaoMeiYouRen'], + '/bbs/user-post/:uid': ['CaoMeiYouRen'], '/sr/:location?/:category?': ['shinanory'], '/ys/:location?/:category?': ['nczitzk'], }; diff --git a/lib/v2/mihoyo/radar.js b/lib/v2/mihoyo/radar.js index 78f65c799dcb39..e49873a683d399 100644 --- a/lib/v2/mihoyo/radar.js +++ b/lib/v2/mihoyo/radar.js @@ -1,4 +1,13 @@ const bbs = [ + { + title: '米游社 - 用户关注', + docs: 'https://docs.rsshub.app/routes/game#mi-ha-you', + source: '/:game/accountCenter/postList', + target: (params, url) => { + const uid = new URL(url).searchParams.get('id'); + return `/mihoyo/bbs/follow-list/${uid}`; + }, + }, { title: '米游社 - 同人榜', docs: 'https://docs.rsshub.app/routes/game#mi-ha-you', diff --git a/lib/v2/mihoyo/router.js b/lib/v2/mihoyo/router.js index 97e86c37764731..c45443e727a6db 100644 --- a/lib/v2/mihoyo/router.js +++ b/lib/v2/mihoyo/router.js @@ -1,7 +1,8 @@ module.exports = function (router) { + router.get('/bbs/follow-list/:uid', require('./bbs/follow-list')); router.get('/bbs/img-ranking/:game/:routeParams?', require('./bbs/img-ranking')); router.get('/bbs/official/:gids/:type?/:page_size?/:last_id?', require('./bbs/official')); - router.get('/bbs/user-post/:uid/:page_size?', require('./bbs/user-post')); + router.get('/bbs/user-post/:uid', require('./bbs/user-post')); router.get('/sr/:location?/:category?', require('./sr/news')); router.get('/ys/:location?/:category?', require('./ys/news')); }; diff --git a/website/docs/routes/game.mdx b/website/docs/routes/game.mdx index d36048cfc2e1dc..6617ef8644876b 100644 --- a/website/docs/routes/game.mdx +++ b/website/docs/routes/game.mdx @@ -715,9 +715,13 @@ Example:`https://www.iyingdi.com/tz/people/55547` ,id 是 `55547` | 1 | 2 | 3 | +### 米游社 - 用户关注 {#mi-ha-you-mi-you-she-yong-hu-guan-zhu} + + + ### 米游社 - 用户帖子 {#mi-ha-you-mi-you-she-yong-hu-tie-zi} - + ### 原神 {#mi-ha-you-yuan-shen} From 895cf2e92ad48807d8e9d558dc1762bd2fe9dcbb Mon Sep 17 00:00:00 2001 From: CaoMeiYouRen <996881204@qq.com> Date: Thu, 18 Jan 2024 22:15:19 +0800 Subject: [PATCH 26/27] =?UTF-8?q?fix(route):=20=E4=BF=AE=E5=A4=8D=20?= =?UTF-8?q?=E7=B1=B3=E6=B8=B8=E7=A4=BE=E5=B8=96=E5=AD=90=E5=8F=AF=E8=83=BD?= =?UTF-8?q?=E7=BC=BA=E5=A4=B1=E5=B0=81=E9=9D=A2=E7=9A=84=20bug=EF=BC=9B?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20=E7=82=B9=E8=B5=9E=E5=92=8C=E8=AF=84?= =?UTF-8?q?=E8=AE=BA=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/v2/mihoyo/bbs/img-ranking.js | 6 +++++- lib/v2/mihoyo/bbs/user-post.js | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/v2/mihoyo/bbs/img-ranking.js b/lib/v2/mihoyo/bbs/img-ranking.js index e17a0d2edcac87..a960deb2d80f97 100644 --- a/lib/v2/mihoyo/bbs/img-ranking.js +++ b/lib/v2/mihoyo/bbs/img-ranking.js @@ -87,14 +87,18 @@ module.exports = async (ctx) => { throw error; } } - const description = renderDescription(describe || '', Array.from(new Set([e.post.cover, ...e.post.images]))); + const description = renderDescription(describe || '', Array.from(new Set([e.post.cover, ...e.post.images])).filter(Boolean)); const pubDate = parseDate(e.post.created_at * 1000); + const upvotes = e.stat.like_num; + const comments = e.stat.reply_num; return { author, title, link, description, pubDate, + upvotes, + comments, }; }); const data = { diff --git a/lib/v2/mihoyo/bbs/user-post.js b/lib/v2/mihoyo/bbs/user-post.js index c1a213c0e6440a..a3eee54f77266c 100644 --- a/lib/v2/mihoyo/bbs/user-post.js +++ b/lib/v2/mihoyo/bbs/user-post.js @@ -36,14 +36,18 @@ module.exports = async (ctx) => { throw error; } } - const description = renderDescription(describe || '', Array.from(new Set([e.post.cover, ...e.post.images]))); + const description = renderDescription(describe || '', Array.from(new Set([e.post.cover, ...e.post.images])).filter(Boolean)); const pubDate = parseDate(e.post.created_at * 1000); + const upvotes = e.stat.like_num; + const comments = e.stat.reply_num; return { author, title, link, description, pubDate, + upvotes, + comments, }; }); From 4b5773ec42671bf634f63f78a386aacb93ed9ff4 Mon Sep 17 00:00:00 2001 From: CaoMeiYouRen <996881204@qq.com> Date: Fri, 19 Jan 2024 00:37:34 +0800 Subject: [PATCH 27/27] =?UTF-8?q?fix(route):=20=E4=BF=AE=E5=A4=8D=20?= =?UTF-8?q?=E7=B1=B3=E6=B8=B8=E7=A4=BE=E8=B7=AF=E7=94=B1=E7=9A=84=E8=A7=84?= =?UTF-8?q?=E8=8C=83=E5=92=8C=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/v2/mihoyo/bbs/follow-list.js | 7 ++++--- lib/v2/mihoyo/bbs/img-ranking.js | 2 +- lib/v2/mihoyo/bbs/user-post.js | 9 +++++---- website/docs/routes/game.mdx | 4 ++-- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/v2/mihoyo/bbs/follow-list.js b/lib/v2/mihoyo/bbs/follow-list.js index 7bd5951abbb488..8acbf2588cfa2a 100644 --- a/lib/v2/mihoyo/bbs/follow-list.js +++ b/lib/v2/mihoyo/bbs/follow-list.js @@ -8,16 +8,17 @@ const renderDescription = (description, images) => art(path.join(__dirname, '../ module.exports = async (ctx) => { const { uid } = ctx.params; const page_size = ctx.query.limit || '20'; - const query = new URLSearchParams({ + const searchParams = { gids: 2, uid, page_size, - }).toString(); + }; const link = `https://www.miyoushe.com/ys/accountCenter/followList?id=${uid}`; - const url = `https://bbs-api.miyoushe.com/user/wapi/following?${query}`; + const url = `https://bbs-api.miyoushe.com/user/wapi/following`; const response = await got({ method: 'get', url, + searchParams, headers: { Origin: 'https://www.miyoushe.com', Referer: link, diff --git a/lib/v2/mihoyo/bbs/img-ranking.js b/lib/v2/mihoyo/bbs/img-ranking.js index a960deb2d80f97..6d988b7f98e24f 100644 --- a/lib/v2/mihoyo/bbs/img-ranking.js +++ b/lib/v2/mihoyo/bbs/img-ranking.js @@ -87,7 +87,7 @@ module.exports = async (ctx) => { throw error; } } - const description = renderDescription(describe || '', Array.from(new Set([e.post.cover, ...e.post.images])).filter(Boolean)); + const description = renderDescription(describe || '', [...new Set([e.post.cover, ...e.post.images])].filter(Boolean)); const pubDate = parseDate(e.post.created_at * 1000); const upvotes = e.stat.like_num; const comments = e.stat.reply_num; diff --git a/lib/v2/mihoyo/bbs/user-post.js b/lib/v2/mihoyo/bbs/user-post.js index a3eee54f77266c..c68302ae352245 100644 --- a/lib/v2/mihoyo/bbs/user-post.js +++ b/lib/v2/mihoyo/bbs/user-post.js @@ -8,15 +8,16 @@ const renderDescription = (description, images) => art(path.join(__dirname, '../ module.exports = async (ctx) => { const { uid } = ctx.params; const size = ctx.query.limit || '20'; - const query = new URLSearchParams({ + const searchParams = { uid, size, - }).toString(); + }; const link = `https://www.miyoushe.com/ys/accountCenter/postList?id=${uid}`; - const url = `https://bbs-api.miyoushe.com/post/wapi/userPost?${query}`; + const url = `https://bbs-api.miyoushe.com/post/wapi/userPost`; const response = await got({ method: 'get', url, + searchParams, }); const list = response?.data?.data?.list; if (!list) { @@ -36,7 +37,7 @@ module.exports = async (ctx) => { throw error; } } - const description = renderDescription(describe || '', Array.from(new Set([e.post.cover, ...e.post.images])).filter(Boolean)); + const description = renderDescription(describe || '', [...new Set([e.post.cover, ...e.post.images])].filter(Boolean)); const pubDate = parseDate(e.post.created_at * 1000); const upvotes = e.stat.like_num; const comments = e.stat.reply_num; diff --git a/website/docs/routes/game.mdx b/website/docs/routes/game.mdx index 6617ef8644876b..236aa5cdcd2254 100644 --- a/website/docs/routes/game.mdx +++ b/website/docs/routes/game.mdx @@ -717,11 +717,11 @@ Example:`https://www.iyingdi.com/tz/people/55547` ,id 是 `55547` ### 米游社 - 用户关注 {#mi-ha-you-mi-you-she-yong-hu-guan-zhu} - + ### 米游社 - 用户帖子 {#mi-ha-you-mi-you-she-yong-hu-tie-zi} - + ### 原神 {#mi-ha-you-yuan-shen}