Skip to content

Commit

Permalink
feat(route): add 逛丢关键字搜索 (#13817)
Browse files Browse the repository at this point in the history
* feat(route): add 逛丢关键字搜索

* Update lib/v2/guangdiu/maintainer.js

* use the href from a.goodname

* Update lib/v2/guangdiu/router.js

* docs: remove duplicated path

---------
  • Loading branch information
Huzhixin00 authored Nov 17, 2023
1 parent 262caf0 commit f7cdf8b
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 7 deletions.
1 change: 1 addition & 0 deletions lib/v2/guangdiu/maintainer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module.exports = {
'/rank': ['fatpandac'],
'/cheaps/:query?': ['fatpandac'],
'/search/:query?': ['Huzhixin00'],
'/:query?': ['Fatpandac'],
};
6 changes: 6 additions & 0 deletions lib/v2/guangdiu/radar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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] : ''}`,
},
],
},
};
1 change: 1 addition & 0 deletions lib/v2/guangdiu/router.js
Original file line number Diff line number Diff line change
@@ -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'));
};
40 changes: 40 additions & 0 deletions lib/v2/guangdiu/search.js
Original file line number Diff line number Diff line change
@@ -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,
};
};
4 changes: 2 additions & 2 deletions website/docs/routes/multimedia.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,7 @@ See [Categories](https://www.javlibrary.com/en/genres.php) to view all categorie

### Videos by makers {#javlibrary-videos-by-makers}

<Route author="Zhixin Hu" example="/javlibrary/videos/maker/arlq/cn" path="/javlibrary/videos/maker/:maker?/:language?/:mode?" paramsDesc={['Maker, S1 NO.1 STYLE by default, as `arlq`', 'Language, see below, Japanese by default, as `ja`', 'Mode, see below, videos with comments (by date) by default, as `1`']} radar="1" rssbud="1">
<Route author="Huzhixin00" example="/javlibrary/videos/maker/arlq/cn" path="/javlibrary/videos/maker/:maker?/:language?/:mode?" paramsDesc={['Maker, S1 NO.1 STYLE by default, as `arlq`', 'Language, see below, Japanese by default, as `ja`', 'Mode, see below, videos with comments (by date) by default, as `1`']} radar="1" rssbud="1">

| videos with comments (by date) | everything (by date) |
| ------------------------------ | -------------------- |
Expand All @@ -933,7 +933,7 @@ See [Categories](https://www.javlibrary.com/en/genres.php) to view all categorie

### Videos by star {#javlibrary-videos-by-star}

<Route author="Diygod junfengP nczitzk" example="/javlibrary/star/abbds/en" path="/javlibrary/star/:id/:language?/:mode?" paramsDesc={['Star id, can be found in URL', 'Language, see below, Japanese by default, as `ja`', 'Mode, see below, videos with comments (by date) by default, as `1`']} radar="1" rssbud="1">
<Route author="DIYgod junfengP nczitzk" example="/javlibrary/star/abbds/en" path="/javlibrary/star/:id/:language?/:mode?" paramsDesc={['Star id, can be found in URL', 'Language, see below, Japanese by default, as `ja`', 'Mode, see below, videos with comments (by date) by default, as `1`']} radar="1" rssbud="1">

| videos with comments (by date) | everything (by date) |
| ------------------------------ | -------------------- |
Expand Down
18 changes: 13 additions & 5 deletions website/docs/routes/shopping.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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}

<Route author="Fatpandac" example="/guangdiu/k=daily" path="/guangdiu/:query?" paramsDesc={['链接参数,对应网址问号后的内容']}/>
<Route author="Fatpandac" example="/guangdiu/k=daily" path="/guangdiu/:query?" paramsDesc={['链接参数,对应网址问号后的内容']}>

### 海外折扣 {#guang-diu-hai-wai-zhe-kou}
:::tip

海外折扣: [`/guangdiu/k=daily&c=us`](https://rsshub.app/guangdiu/k=daily&c=us)

<Route author="Fatpandac" example="/guangdiu/k=daily&c=us" path="/guangdiu/:query?" paramsDesc={['链接参数,对应网址问号后的内容']}/>
:::

</Route>

### 一小时风云榜 {#guang-diu-yi-xiao-shi-feng-yun-bang}

Expand All @@ -353,6 +357,10 @@ For instance, in `https://www.zagg.com/en_us/new-arrivals?brand=164&cat=3038%2C3

<Route author="Fatpandac" example="/guangdiu/cheaps/k=clothes" path="/guangdiu/cheaps/:query?" paramsDesc={['链接参数,对应网址问号后的内容']}/>

### 关键字搜索 {#guang-diu-guan-jian-zi-sou-suo}

<Route author="Huzhixin00" example="/guangdiu/search/k=百度网盘" path="/guangdiu/search/:query?" paramsDesc={['链接参数,对应网址问号后的内容']}/>

## 好好住 {#hao-hao-zhu}

### 整屋案例 {#hao-hao-zhu-zheng-wu-an-li}
Expand Down Expand Up @@ -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}

<Route author="sanmmm nczitzk" example="/getitfree/search/windows" path="/getitfree/search/:keyword" paramsDesc={['关键字']} radar="1" rssbud="1"/>
<Route author="sanmmm nczitzk" example="/getitfree/search/windows" path="/getitfree/search/:keyword" paramsDesc={['关键字']} radar="1" rssbud="1"/>

0 comments on commit f7cdf8b

Please sign in to comment.