fix: outdated route DoNews (#6522)

This commit is contained in:
Laam Pui
2020-12-26 05:49:31 +00:00
committed by GitHub
parent c72f9d4bbf
commit 50d31266c8
3 changed files with 7 additions and 12 deletions
+3 -3
View File
@@ -164,9 +164,9 @@ pageClass: routes
<Route author="HenryQW" example="/donews" path="/donews/:column?" :paramsDesc="['栏目代码, 默认为首页.']">
| 首页 | 商业 | 创业 | 互娱 | 科技 | 专栏 |
| ---- | ------- | -------- | ---- | ---------- | ------- |
| (空) | company | business | ent | technology | idonews |
| 首页 | 商业 | 创业 | 互娱 | 科技 | 专栏 |
| ---- | ------- | -------- | ---- | ------- | ------- |
| (空) | company | business | ent | digital | idonews |
</Route>
+1 -2
View File
@@ -28,8 +28,7 @@ module.exports = async (ctx) => {
switch (column) {
case '':
// 首页轮播
list = $('.focues.hide > ul > li > a').get();
list = list.concat($('.fl.w840 > .block > dl > dd > h3 > a').slice(0, 7).get());
list = $('a.news-item').get();
break;
case 'ent':
+3 -7
View File
@@ -1,19 +1,15 @@
const cheerio = require('cheerio');
const got = require('@/utils/got');
const date = require('@/utils/date');
const ProcessFeed = async (link) => {
const response = await got.get(link);
const $ = cheerio.load(response.data);
const meta = $($('#main .fl')[0]);
return {
title: $('h1').text() || $($('h2')[1]).text(),
author: meta.find('span:nth-child(1)').text(),
title: $('.detail-con h1').text() || $('.detail-con h2').text().replace('{{news.title}}', ''),
author: $('.tag > .fl > span:nth-child(2)').text().replace('{{news.author}}', ''),
description: $('.article-con').html(),
pubDate: date(meta.find('span:nth-child(2)').text(), 8),
pubDate: new Date($('.tag > .fl > span:nth-child(1)').text().replace('{{news.timeFormat}}', '')),
link,
};
};