-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
1 parent
262caf0
commit f7cdf8b
Showing
6 changed files
with
63 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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')); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters