mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-11 15:47:48 +08:00
@@ -2721,6 +2721,8 @@ board 和 build 可在[这里](http://api.ineal.me/tss/status)查看
|
|||||||
|
|
||||||
<route name="标签" author="xyqfer" example="/huxiu/tag/291" path="/huxiu/tag/:id" :paramsDesc="['标签 id']" />
|
<route name="标签" author="xyqfer" example="/huxiu/tag/291" path="/huxiu/tag/:id" :paramsDesc="['标签 id']" />
|
||||||
|
|
||||||
|
<route name="搜索" author="xyqfer" example="/huxiu/search/%E8%99%8E%E5%97%85%E6%97%A9%E6%8A%A5" path="/huxiu/search/:keyword" :paramsDesc="['关键字']" />
|
||||||
|
|
||||||
### 扇贝
|
### 扇贝
|
||||||
|
|
||||||
<route name="打卡" author="DIYgod" example="/shanbay/checkin/ddwej" path="/shanbay/checkin/:id" :paramsDesc="['用户 id']" />
|
<route name="打卡" author="DIYgod" example="/shanbay/checkin/ddwej" path="/shanbay/checkin/:id" :paramsDesc="['用户 id']" />
|
||||||
|
|||||||
@@ -923,6 +923,7 @@ router.get('/zimuzu/resource/:id?', require('./routes/zimuzu/resource'));
|
|||||||
|
|
||||||
// 虎嗅
|
// 虎嗅
|
||||||
router.get('/huxiu/tag/:id', require('./routes/huxiu/tag'));
|
router.get('/huxiu/tag/:id', require('./routes/huxiu/tag'));
|
||||||
|
router.get('/huxiu/search/:keyword', require('./routes/huxiu/search'));
|
||||||
|
|
||||||
// Steam
|
// Steam
|
||||||
router.get('/steam/search/:params', require('./routes/steam/search'));
|
router.get('/steam/search/:params', require('./routes/steam/search'));
|
||||||
|
|||||||
41
lib/routes/huxiu/search.js
Normal file
41
lib/routes/huxiu/search.js
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
const axios = require('../../utils/axios');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const { keyword } = ctx.params;
|
||||||
|
const url = `https://www.huxiu.com/search.html?s=${encodeURIComponent(keyword)}&sort=dateline:desc`;
|
||||||
|
const response = await axios({
|
||||||
|
method: 'get',
|
||||||
|
url,
|
||||||
|
headers: {
|
||||||
|
Referer: url,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const data = response.data;
|
||||||
|
const $ = cheerio.load(data);
|
||||||
|
const list = $('.search-wrap-list-ul > li')
|
||||||
|
.map((index, elem) => {
|
||||||
|
const $elem = $(elem);
|
||||||
|
const $link = $elem.find('a').eq(0);
|
||||||
|
const title = $link.text();
|
||||||
|
const time = $elem.find('.time').text();
|
||||||
|
const link = $link.attr('href');
|
||||||
|
const description = $elem.find('.mob-summay').text();
|
||||||
|
|
||||||
|
return {
|
||||||
|
title,
|
||||||
|
link: `https://www.huxiu.com${link}`,
|
||||||
|
description,
|
||||||
|
pubDate: new Date(time).toUTCString(),
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.get();
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: `虎嗅-${keyword}`,
|
||||||
|
link: url,
|
||||||
|
description: $('meta[name="description"]').attr('content'),
|
||||||
|
item: list,
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user