Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:DIYgod/RSSHub
- Loading branch information
Showing
17 changed files
with
474 additions
and
22 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
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
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
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
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
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 |
---|---|---|
@@ -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 !== ''), | ||
}; | ||
}; |
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,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 !== ''), | ||
}; | ||
}; |
Oops, something went wrong.