rsshub 1.0.0-master.f97cdb2 → 1.0.0-master.fa3428f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/config.js +3 -1
- package/lib/radar-rules.js +0 -92
- package/lib/router.js +68 -71
- package/lib/routes/tencent/wechat/miniprogram/framework.js +4 -2
- package/lib/utils/common-config.js +4 -0
- package/lib/utils/parse-date.js +8 -7
- package/lib/utils/rand-user-agent.js +29 -0
- package/lib/utils/request-wrapper.js +2 -5
- package/lib/utils/wechat-mp.js +106 -10
- package/lib/v2/agirls/index.js +6 -0
- package/lib/v2/bilibili/video.js +1 -0
- package/lib/v2/bookfere/category.js +36 -0
- package/lib/v2/bookfere/maintainer.js +3 -0
- package/lib/v2/bookfere/radar.js +11 -0
- package/lib/v2/bookfere/router.js +3 -0
- package/lib/v2/cankaoxiaoxi/index.js +81 -0
- package/lib/v2/cankaoxiaoxi/maintainer.js +3 -0
- package/lib/v2/cankaoxiaoxi/radar.js +61 -0
- package/lib/v2/cankaoxiaoxi/router.js +3 -0
- package/lib/{routes → v2}/cctv/category.js +1 -1
- package/lib/{routes → v2}/cctv/jx.js +6 -1
- package/lib/{routes → v2}/cctv/lm.js +1 -1
- package/lib/v2/cctv/maintainer.js +7 -0
- package/lib/v2/cctv/radar.js +41 -0
- package/lib/v2/cctv/router.js +7 -0
- package/lib/{routes → v2}/cctv/special.js +6 -4
- package/lib/{routes → v2}/cctv/utils/mzzlbg.js +8 -6
- package/lib/{routes → v2}/cctv/utils/news.js +25 -22
- package/lib/{routes → v2}/cctv/utils/xinwen1j1.js +20 -17
- package/lib/v2/cctv/xwlb.js +50 -0
- package/lib/v2/chinacef/experts.js +38 -0
- package/lib/v2/chinacef/hot.js +38 -0
- package/lib/v2/chinacef/index.js +39 -0
- package/lib/v2/chinacef/maintainer.js +5 -0
- package/lib/v2/chinacef/radar.js +25 -0
- package/lib/v2/chinacef/router.js +5 -0
- package/lib/v2/{wechat → chinacef}/templates/description.art +0 -0
- package/lib/v2/chinacef/utils.js +55 -0
- package/lib/v2/chinanews/index.js +65 -0
- package/lib/v2/chinanews/maintainer.js +3 -0
- package/lib/v2/chinanews/radar.js +13 -0
- package/lib/v2/chinanews/router.js +3 -0
- package/lib/v2/cnbeta/index.js +2 -1
- package/lib/v2/cnbeta/utils.js +1 -0
- package/lib/v2/dapenti/maintainer.js +4 -0
- package/lib/v2/dapenti/radar.js +27 -0
- package/lib/v2/dapenti/router.js +4 -0
- package/lib/{routes → v2}/dapenti/subject.js +1 -1
- package/lib/{routes → v2}/dapenti/tugua.js +1 -1
- package/lib/v2/dapenti/utils.js +75 -0
- package/lib/{routes → v2}/dongqiudi/daily.js +10 -13
- package/lib/v2/dongqiudi/maintainer.js +8 -0
- package/lib/{routes → v2}/dongqiudi/player_news.js +0 -0
- package/lib/v2/dongqiudi/radar.js +45 -0
- package/lib/{routes → v2}/dongqiudi/result.js +2 -1
- package/lib/v2/dongqiudi/router.js +8 -0
- package/lib/{routes → v2}/dongqiudi/special.js +0 -0
- package/lib/{routes → v2}/dongqiudi/team_news.js +0 -0
- package/lib/{routes → v2}/dongqiudi/top_news.js +12 -15
- package/lib/{routes → v2}/dongqiudi/utils.js +47 -28
- package/lib/v2/dut/defaults.js +53 -0
- package/lib/v2/dut/index.js +78 -0
- package/lib/v2/dut/maintainer.js +14 -0
- package/lib/v2/dut/radar.js +109 -0
- package/lib/v2/dut/router.js +4 -0
- package/lib/v2/dut/shortcuts.js +77 -0
- package/lib/{routes → v2}/dx2025/index.js +0 -0
- package/lib/v2/dx2025/maintainer.js +3 -0
- package/lib/v2/dx2025/radar.js +19 -0
- package/lib/v2/dx2025/router.js +3 -0
- package/lib/v2/e-hentai/radar.js +21 -3
- package/lib/v2/eagle/blog.js +47 -0
- package/lib/{routes → v2}/eagle/changelog.js +3 -1
- package/lib/v2/eagle/maintainer.js +4 -0
- package/lib/v2/eagle/radar.js +101 -0
- package/lib/v2/eagle/router.js +4 -0
- package/lib/{routes → v2}/ehentai/ehapi.js +50 -21
- package/lib/{routes → v2}/ehentai/favorites.js +4 -2
- package/lib/v2/ehentai/maintainer.js +5 -0
- package/lib/v2/ehentai/router.js +5 -0
- package/lib/{routes → v2}/ehentai/search.js +5 -3
- package/lib/{routes → v2}/ehentai/tag.js +4 -2
- package/lib/v2/firefox/index.js +7 -2
- package/lib/v2/fortunechina/index.js +1 -1
- package/lib/v2/github/comments.js +7 -0
- package/lib/v2/gitpod/blog.js +8 -0
- package/lib/v2/gov/maintainer.js +1 -0
- package/lib/v2/gov/nrta/news.js +63 -0
- package/lib/v2/gov/radar.js +11 -0
- package/lib/v2/gov/router.js +1 -0
- package/lib/v2/guancha/index.js +1 -1
- package/lib/v2/guangdiu/cheaps.js +28 -0
- package/lib/v2/guangdiu/index.js +44 -0
- package/lib/v2/guangdiu/maintainer.js +5 -0
- package/lib/v2/guangdiu/radar.js +25 -0
- package/lib/v2/guangdiu/rank.js +38 -0
- package/lib/v2/guangdiu/router.js +5 -0
- package/lib/{routes/guokr/calendar.js → v2/guokr/channel.js} +2 -2
- package/lib/v2/guokr/maintainer.js +4 -0
- package/lib/v2/guokr/radar.js +19 -0
- package/lib/v2/guokr/router.js +4 -0
- package/lib/{routes → v2}/guokr/scientific.js +3 -3
- package/lib/v2/hkej/index.js +9 -15
- package/lib/v2/hkepc/index.js +8 -0
- package/lib/v2/hket/index.js +10 -2
- package/lib/v2/huangz/index.js +29 -0
- package/lib/v2/huangz/maintainer.js +3 -0
- package/lib/v2/huangz/radar.js +13 -0
- package/lib/v2/huangz/router.js +3 -0
- package/lib/v2/huanqiu/index.js +65 -0
- package/lib/v2/huanqiu/maintainer.js +3 -0
- package/lib/v2/huanqiu/radar.js +13 -0
- package/lib/v2/huanqiu/router.js +3 -0
- package/lib/v2/miris/blog.js +19 -0
- package/lib/v2/miris/maintainer.js +3 -0
- package/lib/v2/miris/radar.js +11 -0
- package/lib/v2/miris/router.js +3 -0
- package/lib/v2/news/whxw.js +2 -2
- package/lib/v2/npm/package.js +1 -1
- package/lib/v2/npm/router.js +1 -1
- package/lib/v2/qbittorrent/maintainer.js +3 -0
- package/lib/v2/qbittorrent/news.js +59 -0
- package/lib/v2/qbittorrent/radar.js +13 -0
- package/lib/v2/qbittorrent/router.js +3 -0
- package/lib/v2/rsshub/sponsors.js +1 -0
- package/lib/{routes → v2}/sciencenet/blog.js +17 -12
- package/lib/v2/sciencenet/maintainer.js +4 -0
- package/lib/v2/sciencenet/radar.js +19 -0
- package/lib/v2/sciencenet/router.js +4 -0
- package/lib/v2/sciencenet/user.js +65 -0
- package/lib/v2/sdu/cmse.js +59 -0
- package/lib/v2/sdu/cs.js +57 -0
- package/lib/v2/sdu/data.js +110 -0
- package/lib/v2/sdu/epe.js +55 -0
- package/lib/v2/sdu/extractor/index.js +15 -0
- package/lib/v2/sdu/extractor/sdrj.js +21 -0
- package/lib/v2/sdu/extractor/view.js +21 -0
- package/lib/v2/sdu/extractor/wh/jwc.js +24 -0
- package/lib/v2/sdu/extractor/wh/news.js +21 -0
- package/lib/v2/sdu/maintainer.js +9 -0
- package/lib/v2/sdu/mech.js +60 -0
- package/lib/v2/sdu/radar.js +159 -0
- package/lib/v2/sdu/router.js +9 -0
- package/lib/v2/sdu/sc.js +61 -0
- package/lib/v2/sdu/wh/jwc.js +42 -0
- package/lib/v2/sdu/wh/news.js +38 -0
- package/lib/v2/stratechery/index.js +20 -0
- package/lib/v2/stratechery/maintainer.js +3 -0
- package/lib/v2/stratechery/radar.js +11 -0
- package/lib/v2/stratechery/router.js +3 -0
- package/lib/{routes → v2}/taptap/changelog.js +2 -1
- package/lib/v2/taptap/maintainer.js +5 -0
- package/lib/v2/taptap/radar.js +25 -0
- package/lib/v2/taptap/review.js +69 -0
- package/lib/v2/taptap/router.js +5 -0
- package/lib/v2/taptap/templates/videoPost.art +2 -0
- package/lib/v2/taptap/topic.js +79 -0
- package/lib/v2/taptap/utils.js +48 -0
- package/lib/v2/thecover/channel.js +66 -0
- package/lib/v2/thecover/maintainer.js +3 -0
- package/lib/v2/thecover/radar.js +13 -0
- package/lib/v2/thecover/router.js +3 -0
- package/lib/{routes → v2}/twreporter/category.js +7 -12
- package/lib/{routes → v2}/twreporter/fetch_article.js +5 -4
- package/lib/v2/twreporter/maintainer.js +5 -0
- package/lib/{routes → v2}/twreporter/newest.js +8 -13
- package/lib/v2/twreporter/photography.js +46 -0
- package/lib/v2/twreporter/radar.js +25 -0
- package/lib/v2/twreporter/router.js +5 -0
- package/lib/{routes/tencent → v2}/wechat/announce.js +3 -2
- package/lib/v2/wechat/ce.js +69 -0
- package/lib/v2/wechat/data258.js +137 -0
- package/lib/v2/wechat/ershcimi.js +35 -0
- package/lib/{routes/tencent → v2}/wechat/feeds.js +0 -0
- package/lib/v2/wechat/maintainer.js +11 -0
- package/lib/{routes/tencent → v2}/wechat/mp.js +0 -0
- package/lib/{routes/tencent → v2}/wechat/msgalbum.js +0 -0
- package/lib/v2/wechat/radar.js +76 -1
- package/lib/v2/wechat/router.js +11 -0
- package/lib/{routes/tencent → v2}/wechat/tgchannel.js +0 -0
- package/lib/{routes/tencent → v2}/wechat/uread.js +0 -0
- package/lib/{routes/tencent → v2}/wechat/wemp.js +0 -0
- package/lib/{routes/tencent → v2}/wechat/wxnmh.js +0 -0
- package/lib/{routes → v2}/xueqiu/favorite.js +2 -1
- package/lib/v2/xueqiu/fund.js +50 -0
- package/lib/{routes → v2}/xueqiu/hots.js +2 -1
- package/lib/v2/xueqiu/maintainer.js +10 -0
- package/lib/v2/xueqiu/radar.js +60 -0
- package/lib/v2/xueqiu/router.js +10 -0
- package/lib/{routes → v2}/xueqiu/snb.js +2 -1
- package/lib/{routes → v2}/xueqiu/stock_comments.js +4 -20
- package/lib/{routes → v2}/xueqiu/stock_info.js +2 -1
- package/lib/v2/xueqiu/templates/comments_description.art +10 -0
- package/lib/{routes → v2}/xueqiu/user.js +2 -1
- package/lib/{routes → v2}/xueqiu/user_stock.js +3 -2
- package/lib/v2/yunspe/maintainer.js +3 -0
- package/lib/v2/yunspe/newsflash.js +42 -0
- package/lib/v2/yunspe/radar.js +13 -0
- package/lib/v2/yunspe/router.js +3 -0
- package/lib/{routes → v2}/yystv/category.js +8 -8
- package/lib/{routes → v2}/yystv/docs.js +2 -2
- package/lib/v2/yystv/maintainer.js +4 -0
- package/lib/v2/yystv/radar.js +49 -0
- package/lib/v2/yystv/router.js +4 -0
- package/lib/{routes/universities → v2}/zju/career/index.js +14 -13
- package/lib/{routes/universities → v2}/zju/cst/custom.js +2 -1
- package/lib/{routes/universities → v2}/zju/cst/index.js +20 -24
- package/lib/v2/zju/grs/index.js +43 -0
- package/lib/v2/zju/list.js +66 -0
- package/lib/v2/zju/maintainer.js +8 -0
- package/lib/v2/zju/physics/index.js +52 -0
- package/lib/v2/zju/radar.js +139 -0
- package/lib/v2/zju/router.js +8 -0
- package/lib/views/atom.art +13 -1
- package/lib/views/welcome.art +4 -1
- package/package.json +13 -12
- package/lib/routes/cctv/xwlb.js +0 -48
- package/lib/routes/dapenti/utils.js +0 -73
- package/lib/routes/taptap/review.js +0 -39
- package/lib/routes/taptap/topic.js +0 -85
- package/lib/routes/tencent/wechat/_README +0 -1
- package/lib/routes/tencent/wechat/ce.js +0 -40
- package/lib/routes/tencent/wechat/ershcimi.js +0 -43
- package/lib/routes/twreporter/photography.js +0 -57
- package/lib/routes/universities/dut/index.js +0 -60
- package/lib/routes/universities/dut/subsite.js +0 -50
- package/lib/routes/universities/sdu/cmse.js +0 -55
- package/lib/routes/universities/sdu/cs.js +0 -55
- package/lib/routes/universities/sdu/epe.js +0 -54
- package/lib/routes/universities/sdu/mech.js +0 -58
- package/lib/routes/universities/sdu/sc.js +0 -56
- package/lib/routes/universities/zju/grs/index.js +0 -44
- package/lib/routes/universities/zju/list.js +0 -78
- package/lib/routes/universities/zju/physics/index.js +0 -55
- package/lib/routes/xueqiu/fund.js +0 -71
- package/lib/v2/wechat/templates/image.art +0 -1
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
const got = require('@/utils/got');
|
|
2
|
-
const cheerio = require('cheerio');
|
|
3
|
-
|
|
4
|
-
module.exports = async (ctx) => {
|
|
5
|
-
const id = ctx.params.id;
|
|
6
|
-
const order = ctx.params.order;
|
|
7
|
-
|
|
8
|
-
let url = `https://www.taptap.com/app/${id}/review`;
|
|
9
|
-
|
|
10
|
-
if (order === 'update' || order === 'hot' || order === 'spent') {
|
|
11
|
-
url += `?order=${order}`;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const reviews_list_response = await got.get(url);
|
|
15
|
-
const $ = cheerio.load(reviews_list_response.data);
|
|
16
|
-
|
|
17
|
-
const app_img = $('.header-icon-body > img').attr('src');
|
|
18
|
-
const app_name = $('.breadcrumb > li.active').text();
|
|
19
|
-
const order_name = $('.taptap-review-title.section-title li.active').text().trim();
|
|
20
|
-
const reviews_list = $('.review-item-text').toArray();
|
|
21
|
-
|
|
22
|
-
ctx.state.data = {
|
|
23
|
-
title: `TapTap评价 ${app_name} - ${order_name}排序`,
|
|
24
|
-
link: url,
|
|
25
|
-
image: app_img,
|
|
26
|
-
item: reviews_list.map((review) => {
|
|
27
|
-
review = $(review);
|
|
28
|
-
const score = review.find('.colored').attr('style').match(/\d+/)[0] / 14;
|
|
29
|
-
const author = review.find('.item-text-header > .taptap-user ').first().text().trim();
|
|
30
|
-
return {
|
|
31
|
-
title: `${author} - ${score}星`,
|
|
32
|
-
author,
|
|
33
|
-
description: review.find('.item-text-body').html(),
|
|
34
|
-
link: review.find('a.text-header-time').attr('href'),
|
|
35
|
-
pubDate: new Date(review.find('a.text-header-time [data-dynamic-time]').text().trim()),
|
|
36
|
-
};
|
|
37
|
-
}),
|
|
38
|
-
};
|
|
39
|
-
};
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
const got = require('@/utils/got');
|
|
2
|
-
const cheerio = require('cheerio');
|
|
3
|
-
|
|
4
|
-
module.exports = async (ctx) => {
|
|
5
|
-
const id = ctx.params.id;
|
|
6
|
-
const label = ctx.params.label;
|
|
7
|
-
|
|
8
|
-
let url = `https://www.taptap.com/app/${id}/topic`;
|
|
9
|
-
|
|
10
|
-
if (label === 'elite' || label === 'official' || label === 'all') {
|
|
11
|
-
url += `?type=${label}`;
|
|
12
|
-
} else if (/^\d+$/.test(label)) {
|
|
13
|
-
url += `?group_label_id=${label}`;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const topics_list_response = await got.get(url);
|
|
17
|
-
const topics_list_data = topics_list_response.data;
|
|
18
|
-
const $ = cheerio.load(topics_list_data);
|
|
19
|
-
|
|
20
|
-
const app_img = $('.group-info > a > img').attr('src');
|
|
21
|
-
const app_name = $('.group-detail > h2 > a').first().text();
|
|
22
|
-
const label_name = $('.tab-label a.active span').text();
|
|
23
|
-
const topics_list = $('.item-content').get();
|
|
24
|
-
|
|
25
|
-
const parseContent = (htmlString) => {
|
|
26
|
-
const $ = cheerio.load(htmlString);
|
|
27
|
-
|
|
28
|
-
const author = $('.user-name-identity');
|
|
29
|
-
const content = $('.bbcode-body').first();
|
|
30
|
-
const time = $('.topic-update-time').length === 0 ? $('.topic-info [data-dynamic-time]') : $('.topic-update-time [data-dynamic-time]');
|
|
31
|
-
const pub_date = time.length === 0 ? new Date() : new Date(time.text().trim());
|
|
32
|
-
|
|
33
|
-
const images = $('img');
|
|
34
|
-
for (let k = 0; k < images.length; k++) {
|
|
35
|
-
$(images[k]).replaceWith(`<img src="${$(images[k]).attr('data-origin-url')}" />`);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return {
|
|
39
|
-
author: author.text().trim(),
|
|
40
|
-
description: content.html(),
|
|
41
|
-
pubDate: pub_date,
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const out = await Promise.all(
|
|
46
|
-
topics_list.map(async (item) => {
|
|
47
|
-
const $ = cheerio.load(item);
|
|
48
|
-
const title = $('.content-text > a').first();
|
|
49
|
-
const link = title.attr('href');
|
|
50
|
-
|
|
51
|
-
const cache = await ctx.cache.get(link);
|
|
52
|
-
if (cache) {
|
|
53
|
-
return Promise.resolve(JSON.parse(cache));
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const topic = {
|
|
57
|
-
title: title.text().trim(),
|
|
58
|
-
link,
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
try {
|
|
62
|
-
const topic_response = await got.get(link);
|
|
63
|
-
const result = parseContent(topic_response.data);
|
|
64
|
-
if (!result.description) {
|
|
65
|
-
return Promise.resolve('');
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
topic.author = result.author;
|
|
69
|
-
topic.description = result.description;
|
|
70
|
-
topic.pubDate = result.pubDate;
|
|
71
|
-
} catch (err) {
|
|
72
|
-
return Promise.resolve('');
|
|
73
|
-
}
|
|
74
|
-
ctx.cache.set(link, JSON.stringify(topic));
|
|
75
|
-
return Promise.resolve(topic);
|
|
76
|
-
})
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
ctx.state.data = {
|
|
80
|
-
title: `${app_name} - ${label_name} - TapTap论坛`,
|
|
81
|
-
link: url,
|
|
82
|
-
image: app_img,
|
|
83
|
-
item: out.filter((item) => item !== ''),
|
|
84
|
-
};
|
|
85
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Make sure you read lib/utils/wechat-mp.js before adding a new route.
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
const parser = require('@/utils/rss-parser');
|
|
2
|
-
const got = require('@/utils/got');
|
|
3
|
-
const cheerio = require('cheerio');
|
|
4
|
-
|
|
5
|
-
module.exports = async (ctx) => {
|
|
6
|
-
const { id } = ctx.params;
|
|
7
|
-
|
|
8
|
-
const feed = await parser.parseURL(`https://posts.careerengine.us/author/${id}/rss`);
|
|
9
|
-
|
|
10
|
-
const items = await Promise.all(
|
|
11
|
-
feed.items.splice(0, 10).map(async (item) => {
|
|
12
|
-
const response = await got.get(item.link);
|
|
13
|
-
|
|
14
|
-
const $ = cheerio.load(response.data);
|
|
15
|
-
const post = $('.post');
|
|
16
|
-
|
|
17
|
-
post.find('img').each((_, img) => {
|
|
18
|
-
const dataSrc = $(img).attr('data-src');
|
|
19
|
-
if (dataSrc) {
|
|
20
|
-
$(img).attr('src', dataSrc);
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
const single = {
|
|
25
|
-
title: item.title,
|
|
26
|
-
description: post.html(),
|
|
27
|
-
pubDate: item.pubDate,
|
|
28
|
-
link: item.link,
|
|
29
|
-
};
|
|
30
|
-
return Promise.resolve(single);
|
|
31
|
-
})
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
ctx.state.data = {
|
|
35
|
-
title: `微信公众号 - ${feed.title}`,
|
|
36
|
-
link: `https://posts.careerengine.us/author/${id}/posts`,
|
|
37
|
-
description: feed.description,
|
|
38
|
-
item: items,
|
|
39
|
-
};
|
|
40
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
const got = require('@/utils/got');
|
|
2
|
-
const cheerio = require('cheerio');
|
|
3
|
-
|
|
4
|
-
module.exports = async (ctx) => {
|
|
5
|
-
const { id } = ctx.params;
|
|
6
|
-
const url = `https://www.ershicimi.com/a/${id}`;
|
|
7
|
-
const response = await got(url);
|
|
8
|
-
const $ = cheerio.load(response.data);
|
|
9
|
-
const list = $('.weui_media_box')
|
|
10
|
-
.map((_, ele) => {
|
|
11
|
-
const $item = cheerio.load(ele);
|
|
12
|
-
return {
|
|
13
|
-
title: $item('.weui_media_title a').text(),
|
|
14
|
-
description: $item('.weui_media_desc').text(),
|
|
15
|
-
link: `https://www.ershicimi.com${$item('.weui_media_title a').attr('href')}`,
|
|
16
|
-
pubDate: new Date($item('.weui_media_extra_info').attr('title')).toUTCString(),
|
|
17
|
-
};
|
|
18
|
-
})
|
|
19
|
-
.get();
|
|
20
|
-
|
|
21
|
-
const items = await Promise.all(
|
|
22
|
-
list.map((item) =>
|
|
23
|
-
ctx.cache.tryGet(item.link, async () => {
|
|
24
|
-
const detailRepsonse = await got({
|
|
25
|
-
method: 'get',
|
|
26
|
-
url: item.link,
|
|
27
|
-
});
|
|
28
|
-
const content = cheerio.load(detailRepsonse.data);
|
|
29
|
-
|
|
30
|
-
item.description = content('.article-content').html() ? content('.article-content').html() : item.description;
|
|
31
|
-
|
|
32
|
-
return item;
|
|
33
|
-
})
|
|
34
|
-
)
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
ctx.state.data = {
|
|
38
|
-
title: `微信公众号 - ${$('span.name').text()}`,
|
|
39
|
-
link: url,
|
|
40
|
-
description: $('div.Profile-sideColumnItemValue').text(),
|
|
41
|
-
item: items,
|
|
42
|
-
};
|
|
43
|
-
};
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
const cheerio = require('cheerio');
|
|
2
|
-
const got = require('@/utils/got');
|
|
3
|
-
|
|
4
|
-
const fetch = require('./fetch_article');
|
|
5
|
-
|
|
6
|
-
module.exports = async (ctx) => {
|
|
7
|
-
const baseURL = 'https://www.twreporter.org';
|
|
8
|
-
const url = baseURL + `/photography`;
|
|
9
|
-
const res = await got.get(url);
|
|
10
|
-
const $ = cheerio.load(res.data);
|
|
11
|
-
const coverList = $('.WPJvn').get();
|
|
12
|
-
const commonList = $('.eVNsZf').get();
|
|
13
|
-
|
|
14
|
-
const coverView = await Promise.all(
|
|
15
|
-
coverList.map(async (item) => {
|
|
16
|
-
const $ = cheerio.load(item);
|
|
17
|
-
const address = baseURL + $('li > a').attr('href');
|
|
18
|
-
const title = $('.gRCDdm').text();
|
|
19
|
-
|
|
20
|
-
const cache = await ctx.cache.get(address);
|
|
21
|
-
if (cache) {
|
|
22
|
-
return Promise.resolve(JSON.parse(cache));
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const single = await fetch(address);
|
|
26
|
-
single.title = title;
|
|
27
|
-
|
|
28
|
-
ctx.cache.set(address, JSON.stringify(single));
|
|
29
|
-
return Promise.resolve(single);
|
|
30
|
-
})
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
const listView = await Promise.all(
|
|
34
|
-
commonList.map(async (item) => {
|
|
35
|
-
const $ = cheerio.load(item);
|
|
36
|
-
const address = baseURL + $('li > a').attr('href');
|
|
37
|
-
const title = $('.etJLWI').text();
|
|
38
|
-
|
|
39
|
-
const cache = await ctx.cache.get(address);
|
|
40
|
-
if (cache) {
|
|
41
|
-
return Promise.resolve(JSON.parse(cache));
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const single = await fetch(address);
|
|
45
|
-
single.title = title;
|
|
46
|
-
|
|
47
|
-
ctx.cache.set(address, JSON.stringify(single));
|
|
48
|
-
return Promise.resolve(single);
|
|
49
|
-
})
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
ctx.state.data = {
|
|
53
|
-
title: `報導者 | 影像`,
|
|
54
|
-
link: url,
|
|
55
|
-
item: coverView.concat(listView),
|
|
56
|
-
};
|
|
57
|
-
};
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
const got = require('@/utils/got');
|
|
2
|
-
const cheerio = require('cheerio');
|
|
3
|
-
const { parseDate } = require('@/utils/parse-date');
|
|
4
|
-
const timezone = require('@/utils/timezone');
|
|
5
|
-
const subsiteDic = require('./subsite.js');
|
|
6
|
-
module.exports = async (ctx) => {
|
|
7
|
-
const subsiteMap = subsiteDic[ctx.params.subsite];
|
|
8
|
-
const typeMap = subsiteMap.typeMap[ctx.params.type];
|
|
9
|
-
const frontUrl = typeMap.url;
|
|
10
|
-
const basePath = typeMap.basePath;
|
|
11
|
-
const response = await got({
|
|
12
|
-
method: 'get',
|
|
13
|
-
url: frontUrl,
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
const data = response.data;
|
|
17
|
-
const $ = cheerio.load(data);
|
|
18
|
-
const list = $(subsiteMap.listSelector)
|
|
19
|
-
.map((index, item) => {
|
|
20
|
-
item = $(item);
|
|
21
|
-
return {
|
|
22
|
-
title: subsiteMap.titleMethod(item),
|
|
23
|
-
// description,
|
|
24
|
-
link: subsiteMap.linkMethod(item),
|
|
25
|
-
pubDate: timezone(parseDate(subsiteMap.pubDateMethod(item), 'YYYY/MM/DD'), +8),
|
|
26
|
-
};
|
|
27
|
-
})
|
|
28
|
-
.get();
|
|
29
|
-
|
|
30
|
-
const entries = await Promise.all(
|
|
31
|
-
list.map(async (item) => {
|
|
32
|
-
const { title, link, pubDate } = item;
|
|
33
|
-
const entryUrl = basePath + link;
|
|
34
|
-
|
|
35
|
-
const cache = await ctx.cache.tryGet(entryUrl, async () => {
|
|
36
|
-
const response = await got({
|
|
37
|
-
method: 'get',
|
|
38
|
-
url: entryUrl,
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
const $ = cheerio.load(response.data);
|
|
42
|
-
const description = subsiteMap.descriptionMethod($);
|
|
43
|
-
const entry = {
|
|
44
|
-
title,
|
|
45
|
-
link,
|
|
46
|
-
pubDate,
|
|
47
|
-
description,
|
|
48
|
-
};
|
|
49
|
-
return JSON.stringify(entry);
|
|
50
|
-
});
|
|
51
|
-
return Promise.resolve(JSON.parse(cache));
|
|
52
|
-
})
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
ctx.state.data = {
|
|
56
|
-
title: typeMap.title,
|
|
57
|
-
link: frontUrl,
|
|
58
|
-
item: entries,
|
|
59
|
-
};
|
|
60
|
-
};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
const titleMethod1 = (item) => item.find('a').text();
|
|
2
|
-
const linkMethod1 = (item) => item.find('a').attr().href;
|
|
3
|
-
const pubDateMethod1 = (item) => item.find('span').text();
|
|
4
|
-
const descriptionMethod1 = ($) => {
|
|
5
|
-
const main = $('.v_news_content').html();
|
|
6
|
-
let attachment = $('form ul').html();
|
|
7
|
-
// attachment = (attachment ? attachment : '').replace(/<li>/g, '<li><p>').replace(/<\/li>/g, '</p></li>');
|
|
8
|
-
attachment = (attachment ? attachment : '').replace(/<li>/g, '<br><li>');
|
|
9
|
-
return main + '<br>' + attachment;
|
|
10
|
-
};
|
|
11
|
-
const subsiteDic = {
|
|
12
|
-
teach: {
|
|
13
|
-
listSelector: '.list > ul > li',
|
|
14
|
-
titleMethod: titleMethod1,
|
|
15
|
-
linkMethod: linkMethod1,
|
|
16
|
-
pubDateMethod: pubDateMethod1,
|
|
17
|
-
descriptionMethod: descriptionMethod1,
|
|
18
|
-
typeMap: {
|
|
19
|
-
zytg: { title: '大连理工大学教务处-重要通告', url: 'https://teach.dlut.edu.cn/zytg/zytg.htm', basePath: 'https://teach.dlut.edu.cn/zytg/' },
|
|
20
|
-
xwkd: { title: '大连理工大学教务处-新闻快递', url: 'https://teach.dlut.edu.cn/xwkd/xwkd.htm', basePath: 'https://teach.dlut.edu.cn/xwkd/' },
|
|
21
|
-
qitawenjian: { title: '大连理工大学教务处-其他文件', url: 'https://teach.dlut.edu.cn/qitawenjian/list.jsp?urltype=tree.TreeTempUrl&wbtreeid=1081', basePath: 'https://teach.dlut.edu.cn/qitawenjian/' },
|
|
22
|
-
jiaoxuewenjian: { title: '大连理工大学教务处-教学文件', url: 'https://teach.dlut.edu.cn/jiaoxuewenjian/list.jsp?urltype=tree.TreeTempUrl&wbtreeid=1082', basePath: 'https://teach.dlut.edu.cn/jiaoxuewenjian/' },
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
dutdice: {
|
|
26
|
-
listSelector: '.list01 li',
|
|
27
|
-
titleMethod: titleMethod1,
|
|
28
|
-
linkMethod: linkMethod1,
|
|
29
|
-
pubDateMethod: pubDateMethod1,
|
|
30
|
-
descriptionMethod: descriptionMethod1,
|
|
31
|
-
typeMap: {
|
|
32
|
-
xstong_zhi: { title: '大连理工大学国际处及港澳台办-学生通知', url: 'http://dutdice.dlut.edu.cn/tzgg/xstong_zhi.htm', basePath: 'http://dutdice.dlut.edu.cn/tzgg/' },
|
|
33
|
-
jstz: { title: '大连理工大学国际处及港澳台办-教师通知', url: 'http://dutdice.dlut.edu.cn/tzgg/jstz.htm', basePath: 'http://dutdice.dlut.edu.cn/tzgg/' },
|
|
34
|
-
xwsd: { title: '大连理工大学国际处及港澳台办-新闻速递', url: 'http://dutdice.dlut.edu.cn/xwsd/xxxw.htm', basePath: 'http://dutdice.dlut.edu.cn/xwsd/' },
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
tycgzx: {
|
|
38
|
-
listSelector: '.list li',
|
|
39
|
-
titleMethod: titleMethod1,
|
|
40
|
-
linkMethod: linkMethod1,
|
|
41
|
-
pubDateMethod: pubDateMethod1,
|
|
42
|
-
descriptionMethod: descriptionMethod1,
|
|
43
|
-
typeMap: {
|
|
44
|
-
tzgg: { title: '大连理工大学体育场馆中心-通知公告', url: 'http://tycgzx.dlut.edu.cn/tzgg/tzgg.htm', basePath: 'http://tycgzx.dlut.edu.cn/tzgg/' },
|
|
45
|
-
hdrc: { title: '大连理工大学体育场馆中心-活动日程', url: 'http://tycgzx.dlut.edu.cn/hdrc/hdrc.htm', basePath: 'http://tycgzx.dlut.edu.cn/hdrc/' },
|
|
46
|
-
xwdt: { title: '大连理工大学体育场馆中心-新闻动态', url: 'http://tycgzx.dlut.edu.cn/xwdt/xwdt.htm', basePath: 'http://tycgzx.dlut.edu.cn/xwdt/' },
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
module.exports = subsiteDic;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
const got = require('@/utils/got');
|
|
2
|
-
const cheerio = require('cheerio');
|
|
3
|
-
const url = require('url');
|
|
4
|
-
|
|
5
|
-
const host = 'http://www.cmse.sdu.edu.cn/';
|
|
6
|
-
const typelist = ['通知公告', '学院新闻', '本科生教育', '研究生教育', '学术动态'];
|
|
7
|
-
const urlList = ['zxzx/tzgg.htm', 'zxzx/xyxw.htm', 'zxzx/bksjy.htm', 'zxzx/yjsjy.htm', 'zxzx/xsdt.htm'];
|
|
8
|
-
|
|
9
|
-
module.exports = async (ctx) => {
|
|
10
|
-
const type = parseInt(ctx.params.type) || 0;
|
|
11
|
-
const link = url.resolve(host, urlList[type]);
|
|
12
|
-
const response = await got.get(link);
|
|
13
|
-
|
|
14
|
-
const $ = cheerio.load(response.data);
|
|
15
|
-
|
|
16
|
-
const list = $('#list_right_list a')
|
|
17
|
-
.slice(0, 10)
|
|
18
|
-
.map((i, e) => $(e).attr('href'))
|
|
19
|
-
.get();
|
|
20
|
-
|
|
21
|
-
const out = await Promise.all(
|
|
22
|
-
list
|
|
23
|
-
.filter((e) => e.startsWith('../info'))
|
|
24
|
-
.map(async (itemUrl) => {
|
|
25
|
-
itemUrl = url.resolve(host, itemUrl.slice('3'));
|
|
26
|
-
const cache = await ctx.cache.get(itemUrl);
|
|
27
|
-
if (cache) {
|
|
28
|
-
return Promise.resolve(JSON.parse(cache));
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const response = await got.get(itemUrl);
|
|
32
|
-
const $ = cheerio.load(response.data);
|
|
33
|
-
|
|
34
|
-
const rawDate = $('#show_info').text().split(/\s{4}/);
|
|
35
|
-
let date = rawDate[0].split(':')[1];
|
|
36
|
-
date = date.slice(0, 4) + '-' + date.slice(5, 7) + '-' + date.slice(8, 10) + ' ' + date.slice(12);
|
|
37
|
-
|
|
38
|
-
const single = {
|
|
39
|
-
title: $('#show_title').text().trim(),
|
|
40
|
-
link: itemUrl,
|
|
41
|
-
author: '山东大学材料科学与工程学院',
|
|
42
|
-
description: $('#show_content').html(),
|
|
43
|
-
pubDate: new Date(date),
|
|
44
|
-
};
|
|
45
|
-
ctx.cache.set(itemUrl, JSON.stringify(single));
|
|
46
|
-
return Promise.resolve(single);
|
|
47
|
-
})
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
ctx.state.data = {
|
|
51
|
-
title: `山东大学材料科学与工程学院${typelist[type]}`,
|
|
52
|
-
link,
|
|
53
|
-
item: out,
|
|
54
|
-
};
|
|
55
|
-
};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
const got = require('@/utils/got');
|
|
2
|
-
const cheerio = require('cheerio');
|
|
3
|
-
const url = require('url');
|
|
4
|
-
|
|
5
|
-
const host = 'http://www.cs.sdu.edu.cn/';
|
|
6
|
-
const typelist = ['学院公告', '学术报告', '新闻动态'];
|
|
7
|
-
const urlList = ['index/xygg.htm', 'xwgg/xsbg.htm', 'xwgg/xyxw.htm'];
|
|
8
|
-
|
|
9
|
-
module.exports = async (ctx) => {
|
|
10
|
-
const type = parseInt(ctx.params.type) || 0;
|
|
11
|
-
const link = url.resolve(host, urlList[type]);
|
|
12
|
-
|
|
13
|
-
const response = await got.get(link);
|
|
14
|
-
|
|
15
|
-
const $ = cheerio.load(response.data);
|
|
16
|
-
|
|
17
|
-
const dateDict = {};
|
|
18
|
-
const list = $('.sub_text .news-list')
|
|
19
|
-
.slice(0, 10)
|
|
20
|
-
.map((i, e) => {
|
|
21
|
-
const divs = $(e).children();
|
|
22
|
-
const tlink = 'http://www.cs.sdu.edu.cn/' + $('a', divs[1]).attr('href').substring(3);
|
|
23
|
-
dateDict[tlink] = new Date($(divs[2]).text()).toUTCString();
|
|
24
|
-
return tlink;
|
|
25
|
-
})
|
|
26
|
-
.get();
|
|
27
|
-
|
|
28
|
-
const out = await Promise.all(
|
|
29
|
-
list.map(async (itemUrl) => {
|
|
30
|
-
const cache = await ctx.cache.get(itemUrl);
|
|
31
|
-
if (cache) {
|
|
32
|
-
return Promise.resolve(JSON.parse(cache));
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const response = await got.get(itemUrl);
|
|
36
|
-
const $ = cheerio.load(response.data);
|
|
37
|
-
|
|
38
|
-
const single = {
|
|
39
|
-
title: $('#newsTitle').text().trim(),
|
|
40
|
-
author: '山东大学计算机科学与技术学院',
|
|
41
|
-
description: $('.v_news_content').html(),
|
|
42
|
-
pubDate: dateDict[itemUrl],
|
|
43
|
-
link: itemUrl,
|
|
44
|
-
};
|
|
45
|
-
ctx.cache.set(itemUrl, JSON.stringify(single));
|
|
46
|
-
return Promise.resolve(single);
|
|
47
|
-
})
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
ctx.state.data = {
|
|
51
|
-
title: `山东大学计算机科学与技术学院${typelist[type]}通知`,
|
|
52
|
-
link,
|
|
53
|
-
item: out,
|
|
54
|
-
};
|
|
55
|
-
};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
const got = require('@/utils/got');
|
|
2
|
-
const cheerio = require('cheerio');
|
|
3
|
-
const url = require('url');
|
|
4
|
-
|
|
5
|
-
const host = 'http://www.epe.sdu.edu.cn/';
|
|
6
|
-
const typelist = ['学院动态', '通知公告', '学术论坛'];
|
|
7
|
-
const urlList = ['zxzx/xydt.htm', 'zxzx/tzgg.htm', 'zxzx/xslt.htm'];
|
|
8
|
-
|
|
9
|
-
module.exports = async (ctx) => {
|
|
10
|
-
const type = parseInt(ctx.params.type) || 0;
|
|
11
|
-
const link = url.resolve(host, urlList[type]);
|
|
12
|
-
const response = await got.get(link);
|
|
13
|
-
|
|
14
|
-
const $ = cheerio.load(response.data);
|
|
15
|
-
|
|
16
|
-
const list = $('#page_right_main li a')
|
|
17
|
-
.slice(0, 10)
|
|
18
|
-
.map((i, e) => $(e).attr('href'))
|
|
19
|
-
.get();
|
|
20
|
-
|
|
21
|
-
const out = await Promise.all(
|
|
22
|
-
list
|
|
23
|
-
.filter((e) => e.startsWith('../info'))
|
|
24
|
-
.map(async (itemUrl) => {
|
|
25
|
-
itemUrl = url.resolve(host, itemUrl.slice('3'));
|
|
26
|
-
const cache = await ctx.cache.get(itemUrl);
|
|
27
|
-
if (cache) {
|
|
28
|
-
return Promise.resolve(JSON.parse(cache));
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const response = await got.get(itemUrl);
|
|
32
|
-
const $ = cheerio.load(response.data);
|
|
33
|
-
|
|
34
|
-
const rawDate = $('#show_info').text().split(/\s{4}/);
|
|
35
|
-
const date = rawDate[0].split(':')[1];
|
|
36
|
-
|
|
37
|
-
const single = {
|
|
38
|
-
title: $('#show_title').text().trim(),
|
|
39
|
-
link: itemUrl,
|
|
40
|
-
author: '山东大学能源与动力工程学院',
|
|
41
|
-
description: $('#show_content').html(),
|
|
42
|
-
pubDate: new Date(date),
|
|
43
|
-
};
|
|
44
|
-
ctx.cache.set(itemUrl, JSON.stringify(single));
|
|
45
|
-
return Promise.resolve(single);
|
|
46
|
-
})
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
ctx.state.data = {
|
|
50
|
-
title: `山东大学能源与动力工程学院${typelist[type]}`,
|
|
51
|
-
link,
|
|
52
|
-
item: out,
|
|
53
|
-
};
|
|
54
|
-
};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
const got = require('@/utils/got');
|
|
2
|
-
const cheerio = require('cheerio');
|
|
3
|
-
const url = require('url');
|
|
4
|
-
|
|
5
|
-
const typelist = ['通知公告', '院所新闻', '教学信息', '学术动态', '学院简报'];
|
|
6
|
-
const urlList = ['xwdt/tzgg.htm', 'xwdt/ysxw.htm', 'xwdt/jxxx.htm', 'xwdt/xsdt.htm', 'xwdt/xyjb.htm'];
|
|
7
|
-
const host = 'http://www.mech.sdu.edu.cn/';
|
|
8
|
-
|
|
9
|
-
module.exports = async (ctx) => {
|
|
10
|
-
const type = parseInt(ctx.params.type) || 0;
|
|
11
|
-
const link = url.resolve(host, urlList[type]);
|
|
12
|
-
const response = await got.get(link);
|
|
13
|
-
|
|
14
|
-
const $ = cheerio.load(response.data);
|
|
15
|
-
|
|
16
|
-
const list = $('#page_list li a')
|
|
17
|
-
.slice(0, 10)
|
|
18
|
-
.map((i, e) => $(e).attr('href'))
|
|
19
|
-
.get();
|
|
20
|
-
|
|
21
|
-
const out = await Promise.all(
|
|
22
|
-
list
|
|
23
|
-
.filter((e) => e.startsWith('../info') || e.startsWith('http://www.rd.sdu.edu.cn/'))
|
|
24
|
-
.map(async (itemUrl) => {
|
|
25
|
-
const isFromMech = itemUrl.startsWith('../info');
|
|
26
|
-
if (isFromMech) {
|
|
27
|
-
itemUrl = url.resolve(host, itemUrl.slice('3'));
|
|
28
|
-
}
|
|
29
|
-
const cache = await ctx.cache.get(itemUrl);
|
|
30
|
-
if (cache) {
|
|
31
|
-
return Promise.resolve(JSON.parse(cache));
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const response = await got.get(itemUrl);
|
|
35
|
-
const $ = cheerio.load(response.data);
|
|
36
|
-
|
|
37
|
-
const rawDate = $('#show_info').text().split(/\s{4}/);
|
|
38
|
-
let date = rawDate[0].split(':')[1];
|
|
39
|
-
date = date.slice(0, 4) + '-' + date.slice(5, 7) + '-' + date.slice(8, 10) + ' ' + date.slice(11);
|
|
40
|
-
|
|
41
|
-
const single = {
|
|
42
|
-
title: $('#show_title').text().trim(),
|
|
43
|
-
link: itemUrl,
|
|
44
|
-
author: '山东大学机械工程学院',
|
|
45
|
-
description: $('#show_content').html(),
|
|
46
|
-
pubDate: new Date(date),
|
|
47
|
-
};
|
|
48
|
-
ctx.cache.set(itemUrl, JSON.stringify(single));
|
|
49
|
-
return Promise.resolve(single);
|
|
50
|
-
})
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
ctx.state.data = {
|
|
54
|
-
title: `山东大学机械工程学院${typelist[type]}`,
|
|
55
|
-
link,
|
|
56
|
-
item: out,
|
|
57
|
-
};
|
|
58
|
-
};
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
const got = require('@/utils/got');
|
|
2
|
-
const cheerio = require('cheerio');
|
|
3
|
-
const url = require('url');
|
|
4
|
-
|
|
5
|
-
const host = 'http://www.sc.sdu.edu.cn/';
|
|
6
|
-
const typelist = ['通知公告', '学术动态', '本科教育', '研究生教育'];
|
|
7
|
-
const urlList = ['tzgg.htm', 'kxyj/xsdt/2.htm', 'rcpy/bkjy.htm', 'rcpy/yjsjy.htm'];
|
|
8
|
-
|
|
9
|
-
module.exports = async (ctx) => {
|
|
10
|
-
const type = parseInt(ctx.params.type) || 0;
|
|
11
|
-
const link = url.resolve(host, urlList[type]);
|
|
12
|
-
const response = await got.get(link);
|
|
13
|
-
|
|
14
|
-
const $ = cheerio.load(response.data);
|
|
15
|
-
|
|
16
|
-
const dateDict = {};
|
|
17
|
-
const list = $('.lm_list li')
|
|
18
|
-
.slice(0, 10)
|
|
19
|
-
.map((i, e) => {
|
|
20
|
-
let aLink = $(e).children('a').attr('href');
|
|
21
|
-
// aLink = aLink.slice(3);
|
|
22
|
-
aLink = url.resolve(host, aLink);
|
|
23
|
-
const date = $(e).children('span').text().trim();
|
|
24
|
-
dateDict[aLink] = date;
|
|
25
|
-
return aLink;
|
|
26
|
-
})
|
|
27
|
-
.get();
|
|
28
|
-
|
|
29
|
-
const out = await Promise.all(
|
|
30
|
-
list.map(async (itemUrl) => {
|
|
31
|
-
const cache = await ctx.cache.get(itemUrl);
|
|
32
|
-
if (cache) {
|
|
33
|
-
return Promise.resolve(JSON.parse(cache));
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const response = await got.get(itemUrl);
|
|
37
|
-
const $ = cheerio.load(response.data);
|
|
38
|
-
|
|
39
|
-
const single = {
|
|
40
|
-
title: $('h1.c-title').text().trim(),
|
|
41
|
-
link: itemUrl,
|
|
42
|
-
author: '山东大学软件学院',
|
|
43
|
-
description: $('.v_news_content').html(),
|
|
44
|
-
pubDate: new Date(dateDict[itemUrl]),
|
|
45
|
-
};
|
|
46
|
-
ctx.cache.set(itemUrl, JSON.stringify(single));
|
|
47
|
-
return Promise.resolve(single);
|
|
48
|
-
})
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
ctx.state.data = {
|
|
52
|
-
title: `山东大学软件学院${typelist[type]}`,
|
|
53
|
-
link,
|
|
54
|
-
item: out,
|
|
55
|
-
};
|
|
56
|
-
};
|