mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 23:00:48 +08:00
feat: add haohaozhu (#3978)
This commit is contained in:
@@ -42,6 +42,16 @@ For instance, in https://www.leboncoin.fr/recherche/?**category=10&locations=Par
|
|||||||
|
|
||||||
<Route author="fengkx" example="/duozhuayu/search/JavaScript" path="/duozhuayu/search/:wd" :paramsDesc="['搜索关键词']"/>
|
<Route author="fengkx" example="/duozhuayu/search/JavaScript" path="/duozhuayu/search/:wd" :paramsDesc="['搜索关键词']"/>
|
||||||
|
|
||||||
|
## 好好住
|
||||||
|
|
||||||
|
### 整屋案例
|
||||||
|
|
||||||
|
<Route author="hoilc" example="/haohaozhu/whole-house/日式" path="/haohaozhu/whole-house/:keyword?" :paramsDesc="['分类名或关键字,请使用中文']"/>
|
||||||
|
|
||||||
|
### 发现
|
||||||
|
|
||||||
|
<Route author="hoilc" example="/haohaozhu/discover/厨房" path="/haohaozhu/discover/:keyword?" :paramsDesc="['分类名或关键字,请使用中文']"/>
|
||||||
|
|
||||||
## 京东众筹
|
## 京东众筹
|
||||||
|
|
||||||
### 众筹项目
|
### 众筹项目
|
||||||
|
|||||||
@@ -2233,6 +2233,10 @@ router.get('/2048/bbs/:fid', require('./routes/2048/bbs'));
|
|||||||
// Google News
|
// Google News
|
||||||
router.get('/google/news/:category/:locale', require('./routes/google/news'));
|
router.get('/google/news/:category/:locale', require('./routes/google/news'));
|
||||||
|
|
||||||
|
// 好好住
|
||||||
|
router.get('/haohaozhu/whole-house/:keyword?', require('./routes/haohaozhu/whole-house'));
|
||||||
|
router.get('/haohaozhu/discover/:keyword?', require('./routes/haohaozhu/discover'));
|
||||||
|
|
||||||
// 东北大学
|
// 东北大学
|
||||||
router.get('/neu/news/:type', require('./routes/universities/neu/news'));
|
router.get('/neu/news/:type', require('./routes/universities/neu/news'));
|
||||||
|
|
||||||
|
|||||||
42
lib/routes/haohaozhu/discover.js
Normal file
42
lib/routes/haohaozhu/discover.js
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const keyword = ctx.params.keyword && ctx.params.keyword !== 'all' && ctx.params.keyword !== '全部' ? ctx.params.keyword : '';
|
||||||
|
|
||||||
|
const url = 'https://www.haohaozhu.cn/community/discover';
|
||||||
|
|
||||||
|
const response = await got({
|
||||||
|
method: 'post',
|
||||||
|
url: 'https://www.haohaozhu.cn/f/y/api/Share/AllPhotoInPc',
|
||||||
|
headers: {
|
||||||
|
Referer: url,
|
||||||
|
},
|
||||||
|
form: {
|
||||||
|
keyword: keyword,
|
||||||
|
page: 1,
|
||||||
|
time: new Date().getTime(),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const list = response.data.data.rows;
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: `好好住 - 发现${keyword ? ' - ' + keyword : ''}`,
|
||||||
|
link: url,
|
||||||
|
item: list
|
||||||
|
.map((item) => {
|
||||||
|
if (item.is_advertisement !== 0 || !item.photo || !item.photo.photo_info) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
title: item.photo.photo_info.remark,
|
||||||
|
author: item.photo.user_info.nick,
|
||||||
|
description: item.photo.photo_info.image_list.map((image) => `<img src="${image.ori_pic_url}" style="max-width: 100%;" />`).join(''),
|
||||||
|
link: url,
|
||||||
|
guid: item.photo.photo_info.id,
|
||||||
|
pubDate: new Date(item.photo.photo_info.addtime * 1000),
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.filter((item) => item !== ''),
|
||||||
|
};
|
||||||
|
};
|
||||||
75
lib/routes/haohaozhu/whole-house.js
Normal file
75
lib/routes/haohaozhu/whole-house.js
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const keyword = ctx.params.keyword && ctx.params.keyword !== 'all' && ctx.params.keyword !== '全部' ? ctx.params.keyword : '';
|
||||||
|
|
||||||
|
const url = 'https://www.haohaozhu.cn/community/whole-house';
|
||||||
|
|
||||||
|
const response = await got({
|
||||||
|
method: 'post',
|
||||||
|
url: 'https://www.haohaozhu.cn/f/y/api/Share/GetArticle',
|
||||||
|
headers: {
|
||||||
|
Referer: url,
|
||||||
|
},
|
||||||
|
form: {
|
||||||
|
keyword: keyword,
|
||||||
|
page: 1,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const list = response.data.data.rows;
|
||||||
|
|
||||||
|
const parseContent = (htmlString) => {
|
||||||
|
const $ = cheerio.load(htmlString);
|
||||||
|
|
||||||
|
const content = $('.whole-header').parent();
|
||||||
|
$('.whole-title').remove();
|
||||||
|
$('.whole-user').remove();
|
||||||
|
$('.question').appendTo(content);
|
||||||
|
|
||||||
|
return {
|
||||||
|
description: content.html(),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const out = await Promise.all(
|
||||||
|
list.map(async (item, index) => {
|
||||||
|
const link = `https://www.haohaozhu.cn/community/whole-house-detail/${item.article_id}`;
|
||||||
|
|
||||||
|
const time = new Date();
|
||||||
|
time.setMinutes(time.getMinutes() - index);
|
||||||
|
|
||||||
|
const cache = await ctx.cache.get(link);
|
||||||
|
if (cache) {
|
||||||
|
return Promise.resolve(JSON.parse(cache));
|
||||||
|
}
|
||||||
|
|
||||||
|
const rssitem = {
|
||||||
|
title: item.article_info.title,
|
||||||
|
link: link,
|
||||||
|
author: item.user_info.nick,
|
||||||
|
pubDate: time,
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await got.get(link);
|
||||||
|
const result = parseContent(response.data);
|
||||||
|
if (!result.description) {
|
||||||
|
return Promise.resolve('');
|
||||||
|
}
|
||||||
|
rssitem.description = result.description;
|
||||||
|
} catch (err) {
|
||||||
|
return Promise.resolve('');
|
||||||
|
}
|
||||||
|
ctx.cache.set(link, JSON.stringify(rssitem));
|
||||||
|
return Promise.resolve(rssitem);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: `好好住 - 整屋案例${keyword ? ' - ' + keyword : ''}`,
|
||||||
|
link: url,
|
||||||
|
item: out.filter((item) => item !== ''),
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user