mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat(route): add 逛丢 (#9503)
* feat(route): add 逛丢 * fix(route): fix path
This commit is contained in:
@@ -143,6 +143,24 @@ For instance, in <https://www.leboncoin.fr/recherche/?**category=10&locations=Pa
|
||||
|
||||
<Route author="fengkx" example="/duozhuayu/search/JavaScript" path="/duozhuayu/search/:wd" :paramsDesc="['搜索关键词']"/>
|
||||
|
||||
## 逛丢
|
||||
|
||||
### 国内折扣
|
||||
|
||||
<Route author="Fatpandac" example="/guangdiu/k=daily" path="/guangdiu/:query?" :paramsDesc="['链接参数,对应网址问号后的内容']"/>
|
||||
|
||||
### 海外折扣
|
||||
|
||||
<Route author="Fatpandac" example="/guangdiu/k=daily&c=us" path="/guangdiu/:query?" :paramsDesc="['链接参数,对应网址问号后的内容']"/>
|
||||
|
||||
### 一小时风云榜
|
||||
|
||||
<Route author="Fatpandac" example="/guangdiu/rank" path="/guangdiu/rank"/>
|
||||
|
||||
### 九块九
|
||||
|
||||
<Route author="Fatpandac" example="/guangdiu/cheaps/k=clothes" path="/guangdiu/cheaps/:query?" :paramsDesc="['链接参数,对应网址问号后的内容']"/>
|
||||
|
||||
## 好好住
|
||||
|
||||
### 整屋案例
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
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}/cheaps.php${query ? `?${query}` : ''}`;
|
||||
|
||||
const response = await got(url);
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const items = $('div.cheapitem.rightborder')
|
||||
.map((_index, item) => ({
|
||||
title: $(item).find('div.cheaptitle').text().trim() + $(item).find('a.cheappriceword').text(),
|
||||
link: $(item).find('a.cheappriceword').attr('href'),
|
||||
description: $(item).find('div.cheapimga').html(),
|
||||
pubDate: parseRelativeDate($(item).find('span.cheapaddtimeword').text()),
|
||||
}))
|
||||
.get();
|
||||
|
||||
ctx.state.data = {
|
||||
title: `逛丢 - 九块九`,
|
||||
link: url,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,44 @@
|
||||
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 ?? '';
|
||||
let url;
|
||||
if (query === 'c=us') {
|
||||
url = `${host}/?c=us`;
|
||||
} else {
|
||||
url = `${host}/${query ? `cate.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: new URL($(item).find('div.iteminfoarea > h2 > a').attr('href'), host).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;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `逛丢 - ${query.indexOf('c=us') > -1 ? '海外' : '国内'}`,
|
||||
link: url,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
module.exports = {
|
||||
'/rank': ['fatpandac'],
|
||||
'/cheaps/:query?': ['fatpandac'],
|
||||
'/:query?': ['Fatpandac'],
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
module.exports = {
|
||||
'guangdiu.com': {
|
||||
_name: '逛丢',
|
||||
'.': [
|
||||
{
|
||||
title: '折扣',
|
||||
docs: 'https://docs.rsshub.app/other.html#gu-duo-shu-ju',
|
||||
source: ['/', '/cate.php'],
|
||||
target: (param, url) => `/guangdiu/${url.indexOf('?') > -1 ? url.split('?')[1] : ''}`,
|
||||
},
|
||||
{
|
||||
title: '一小时风云榜',
|
||||
docs: 'https://docs.rsshub.app/other.html#gu-duo-shu-ju',
|
||||
source: ['/rank'],
|
||||
target: '/guangdiu/rank',
|
||||
},
|
||||
{
|
||||
title: '九块九',
|
||||
docs: 'https://docs.rsshub.app/other.html#gu-duo-shu-ju',
|
||||
source: ['/cheaps.php'],
|
||||
target: (param, url) => `/guangdiu/${url.indexOf('?') > -1 ? url.split('?')[1] : ''}`,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,38 @@
|
||||
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 url = `${host}/rank.php`;
|
||||
|
||||
const response = await got(url);
|
||||
const $ = cheerio.load(response.data);
|
||||
const list = $('div.hourrankitem')
|
||||
.map((_index, item) => ({
|
||||
title: $(item).find('a.hourranktitle').text(),
|
||||
link: new URL($(item).find('a.hourranktitle').attr('href'), host).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($('div.hourranktime').text());
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `逛丢 - 一小时风云榜`,
|
||||
link: url,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
module.exports = function (router) {
|
||||
router.get('/rank', require('./rank'));
|
||||
router.get('/cheaps/:query?', require('./cheaps'));
|
||||
router.get('/:query?', require('./index'));
|
||||
};
|
||||
Reference in New Issue
Block a user