@@ -699,6 +699,16 @@ area 分区选项
|
||||
|
||||
<Route author="ciaranchen" example="/houxu/events" path="/houxu/events"/>
|
||||
|
||||
## 互动吧
|
||||
|
||||
### 活动
|
||||
|
||||
<Route author="nczitzk" example="/hudongba/beijing/98-0-2-0-1-1" path="/hudongba/:city/:id" :paramsDesc="['城市,可在选定所在城市后的页面 URL 中找到', '编号,可在选定筛选条件后的页面 URL 中找到']">
|
||||
|
||||
如例子 `/hudongba/beijing/98-0-2-0-1-1` 对应的网址 `https://www.hudongba.com/beijing/98-0-2-0-0-1` 中,`beijing` 即所在城市为北京;`98-0-2-0-0-1` 则是所选择的分类编号,指分类不限、时间不限、综合排序的所有亲子活动。
|
||||
|
||||
</Route>
|
||||
|
||||
## 虎嗅
|
||||
|
||||
### 首页资讯
|
||||
|
||||
@@ -3188,6 +3188,9 @@ router.get('/chuhaibiji', require('./routes/chuhaibiji/index'));
|
||||
// 建宁闲谈
|
||||
router.get('/blogs/jianning', require('./routes/blogs/jianning'));
|
||||
|
||||
// 互动吧
|
||||
router.get('/hudongba/:city/:id', require('./routes/hudongba/index'));
|
||||
|
||||
// 差评
|
||||
router.get('/chaping/banner', require('./routes/chaping/banner'));
|
||||
router.get('/chaping/news/:caty?', require('./routes/chaping/news'));
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const currentUrl = `https://www.hudongba.com/${ctx.params.city}/${ctx.params.id}`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const list = $('ul.find_main_ul li.find_main_li div.find_main_div')
|
||||
.slice(0, 30)
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
const a = item.find('h3.find_main_title a');
|
||||
return {
|
||||
title: a.text().trim(),
|
||||
link: a.attr('href'),
|
||||
description: item.find('div.find_main_fixH').text(),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('div.crumbs-find').text(),
|
||||
link: currentUrl,
|
||||
item: list,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user