feat: add 遠見 gvm.com.tw (#6282)
This commit is contained in:
parent
da9cd91c0d
commit
fa9181fcf1
|
|
@ -1749,6 +1749,15 @@ column 为 third 时可选的 category:
|
|||
|
||||
</Route>
|
||||
|
||||
## 遠見
|
||||
|
||||
<Route author="laampui" example="/gvm/index/health" path="/gvm/index/:category?" :paramsDesc="['見下表, 默認爲 newest']">
|
||||
|
||||
| 最新文章 | 你可能會喜歡 | 名家專欄 | 專題 | 時事熱點 | 政治 | 社會 | 人物報導 | 國際 | 全球焦點 | 兩岸 | 金融理財 | 投資理財 | 保險規劃 | 退休理財 | 金融 Fintech | 房地產 | 總體經濟 | 科技 | 科技趨勢 | 能源 | 產經 | 傳產 | 消費服務 | 生技醫藥 | 傳承轉型 | 創業新創 | 管理 | 農業 | 教育 | 高教 | 技職 | 親子教育 | 國際文教 | 體育 | 好享生活 | 時尚設計 | 心靈成長 | 藝文影視 | 旅遊 | 環境生態 | 健康 | 美食 | 職場生涯 | 調查 | 縣市 | CSR |
|
||||
| -------- | ------------ | -------- | ----- | -------- | -------- | ------- | -------- | ----- | ----------- | --------------------- | -------- | ---------- | --------- | -------- | ------------ | ----------- | -------- | ---- | ---------- | ------ | -------- | -------- | -------- | -------- | -------------------------- | -------- | ---------- | ----------- | --------- | ---------------- | ------------- | -------- | --------------- | ------ | -------- | -------- | ----------- | -------- | ------ | ----------- | ------ | ---- | -------- | ------ | ------ | --- |
|
||||
| newest | recommend | opinion | topic | news | politics | society | figure | world | world_focus | cross_strait_politics | money | investment | insurance | retire | fintech | real_estate | economy | tech | tech_trend | energy | business | industry | service | medical | family_business_succession | startup | management | agriculture | education | higher_education | technological | parent | world_education | sports | life | art | self_growth | film | travel | environment | health | food | career | survey | county | csr |
|
||||
|
||||
</Route>
|
||||
## 装备前线
|
||||
|
||||
### 首页最新帖子
|
||||
|
|
|
|||
|
|
@ -3588,6 +3588,9 @@ router.get('/youdao/latest', require('./routes/youdao/latest'));
|
|||
router.get('/yinxiang/note', require('./routes/yinxiang/note'));
|
||||
router.get('/yinxiang/card/:id?', require('./routes/yinxiang/card'));
|
||||
|
||||
// 遠見 gvm.com.tw
|
||||
router.get('/gvm/index/:category?', require('./routes/gvm/index'));
|
||||
|
||||
// 触乐
|
||||
router.get('/chuapp/index/:category?', require('./routes/chuapp/index'));
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,95 @@
|
|||
const got = require('got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const category = ctx.params.category || 'newest';
|
||||
let suffix = '/newest';
|
||||
|
||||
const options = {
|
||||
newest: '最新文章',
|
||||
recommend: '你可能會喜歡',
|
||||
opinion: '名家專欄',
|
||||
topic: '專題',
|
||||
news: '時事熱點',
|
||||
politics: '政治',
|
||||
society: '社會',
|
||||
figure: '人物報導',
|
||||
world: '國際',
|
||||
world_focus: '全球焦點',
|
||||
cross_strait_politics: '兩岸',
|
||||
money: '金融理財',
|
||||
investment: '投資理財',
|
||||
insurance: '保險規劃',
|
||||
retire: '退休理財',
|
||||
fintech: '金融Fintech',
|
||||
real_estate: '房地產',
|
||||
economy: '總體經濟',
|
||||
tech: '科技',
|
||||
tech_trend: '科技趨勢',
|
||||
energy: '能源',
|
||||
business: '產經',
|
||||
industry: '傳產',
|
||||
service: '消費服務',
|
||||
medical: '生技醫藥',
|
||||
family_business_succession: '傳承轉型',
|
||||
startup: '創業新創',
|
||||
management: '管理',
|
||||
agriculture: '農業',
|
||||
education: '教育',
|
||||
higher_education: '高教',
|
||||
technological: '技職',
|
||||
parent: '親子教育',
|
||||
world_education: '國際文教',
|
||||
sports: '體育',
|
||||
life: '好享生活',
|
||||
art: '時尚設計',
|
||||
self_growth: '心靈成長',
|
||||
film: '藝文影視',
|
||||
travel: '旅遊',
|
||||
environment: '環境生態',
|
||||
health: '健康',
|
||||
food: '美食',
|
||||
career: '職場生涯',
|
||||
survey: '調查',
|
||||
county: '縣市',
|
||||
csr: 'CSR',
|
||||
};
|
||||
|
||||
if (category !== 'newest' && category !== 'recommend') {
|
||||
suffix = `/category/${category}`;
|
||||
}
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: 'https://www.gvm.com.tw' + suffix,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.body);
|
||||
|
||||
const articles = $('#article_list .article-list-item .article-list-item__intro')
|
||||
.map((index, ele) => ({
|
||||
title: $('a', ele).text(),
|
||||
link: $('a', ele).attr('href'),
|
||||
pubDate: new Date($('.time', ele).text()),
|
||||
author: $('.author', ele).text(),
|
||||
}))
|
||||
.get();
|
||||
|
||||
const item = await Promise.all(
|
||||
articles.map(
|
||||
async (item) =>
|
||||
await ctx.cache.tryGet(item.link, async () => {
|
||||
const res = await got.get(item.link);
|
||||
const content = cheerio.load(res.body);
|
||||
item.description = content('.article-content').html();
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `遠見 - ${options[category]}`,
|
||||
link: 'https://www.gvm.com.tw' + suffix,
|
||||
item,
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue