diff --git a/lib/v2/guangdiu/maintainer.js b/lib/v2/guangdiu/maintainer.js index 1b8c2f2f23b592..484b9cd0caae5e 100644 --- a/lib/v2/guangdiu/maintainer.js +++ b/lib/v2/guangdiu/maintainer.js @@ -1,5 +1,6 @@ module.exports = { '/rank': ['fatpandac'], '/cheaps/:query?': ['fatpandac'], + '/search/:query?': ['Huzhixin00'], '/:query?': ['Fatpandac'], }; diff --git a/lib/v2/guangdiu/radar.js b/lib/v2/guangdiu/radar.js index 6f108fe9d95b17..4dd53709d197a7 100644 --- a/lib/v2/guangdiu/radar.js +++ b/lib/v2/guangdiu/radar.js @@ -20,6 +20,12 @@ module.exports = { source: ['/cheaps.php'], target: (param, url) => `/guangdiu/${url.indexOf('?') > -1 ? url.split('?')[1] : ''}`, }, + { + title: '关键字搜索', + docs: 'https://docs.rsshub.app/routes/shopping#guang-diu', + source: ['/search.php'], + target: (param, url) => `/guangdiu/${url.indexOf('?') > -1 ? url.split('?')[1] : ''}`, + }, ], }, }; diff --git a/lib/v2/guangdiu/router.js b/lib/v2/guangdiu/router.js index 85732aa78fe161..4e8bd5d4084c30 100644 --- a/lib/v2/guangdiu/router.js +++ b/lib/v2/guangdiu/router.js @@ -1,5 +1,6 @@ module.exports = function (router) { router.get('/rank', require('./rank')); router.get('/cheaps/:query?', require('./cheaps')); + router.get('/search/:query?', require('./search')); router.get('/:query?', require('./index')); }; diff --git a/lib/v2/guangdiu/search.js b/lib/v2/guangdiu/search.js new file mode 100644 index 00000000000000..6313b62c9fd2af --- /dev/null +++ b/lib/v2/guangdiu/search.js @@ -0,0 +1,40 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseRelativeDate } = require('@/utils/parse-date'); + +const host = 'https://guangdiu.com'; + +module.exports = async (ctx) => { + const query = ctx.params.query ?? ''; + const url = `${host}/${query ? `search.php?${query}` : ''}`; + const response = await got(url); + const $ = cheerio.load(response.data); + const list = $('#mainleft > div.zkcontent > div.gooditem') + .map((_index, item) => ({ + title: $(item).find('a.goodname').text().trim(), + link: `${host}/${$(item).find('a.goodname').attr('href')}`, + })) + .get(); + + const items = await Promise.all( + list.map((item) => + ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got(item.link); + const $ = cheerio.load(detailResponse.data); + + item.description = $('#dabstract').html() + $('a.dgotobutton').html('前往购买'); + item.pubDate = parseRelativeDate($('span.latesttime').text()); + + return item; + }) + ) + ); + + const match = /q=(.+)/.exec(query); + + ctx.state.data = { + title: `逛丢 - ${match[1]}`, + link: url, + item: items, + }; +}; diff --git a/website/docs/routes/multimedia.mdx b/website/docs/routes/multimedia.mdx index 9f9e32c0a3c9aa..bf0aa206e0939e 100644 --- a/website/docs/routes/multimedia.mdx +++ b/website/docs/routes/multimedia.mdx @@ -923,7 +923,7 @@ See [Categories](https://www.javlibrary.com/en/genres.php) to view all categorie ### Videos by makers {#javlibrary-videos-by-makers} - + | videos with comments (by date) | everything (by date) | | ------------------------------ | -------------------- | @@ -933,7 +933,7 @@ See [Categories](https://www.javlibrary.com/en/genres.php) to view all categorie ### Videos by star {#javlibrary-videos-by-star} - + | videos with comments (by date) | everything (by date) | | ------------------------------ | -------------------- | diff --git a/website/docs/routes/shopping.mdx b/website/docs/routes/shopping.mdx index 700622a76ceec0..0f6a4ec33fd291 100644 --- a/website/docs/routes/shopping.mdx +++ b/website/docs/routes/shopping.mdx @@ -337,13 +337,17 @@ For instance, in `https://www.zagg.com/en_us/new-arrivals?brand=164&cat=3038%2C3 ## 逛丢 {#guang-diu} -### 国内折扣 {#guang-diu-guo-nei-zhe-kou} +### 国内折扣 / 海外折扣 {#guang-diu-guo-nei-zhe-kou} - + -### 海外折扣 {#guang-diu-hai-wai-zhe-kou} +:::tip + +海外折扣: [`/guangdiu/k=daily&c=us`](https://rsshub.app/guangdiu/k=daily&c=us) - +::: + + ### 一小时风云榜 {#guang-diu-yi-xiao-shi-feng-yun-bang} @@ -353,6 +357,10 @@ For instance, in `https://www.zagg.com/en_us/new-arrivals?brand=164&cat=3038%2C3 +### 关键字搜索 {#guang-diu-guan-jian-zi-sou-suo} + + + ## 好好住 {#hao-hao-zhu} ### 整屋案例 {#hao-hao-zhu-zheng-wu-an-li} @@ -784,4 +792,4 @@ For instance, in `https://www.zagg.com/en_us/new-arrivals?brand=164&cat=3038%2C3 ### 搜索 {#zheng-ban-zhong-guo-sou-suo} - \ No newline at end of file +