chore: 部分代码优化 (#1674)

This commit is contained in:
Henry Wang
2019-03-04 19:26:09 +08:00
committed by DIYgod
parent 67f41eabb3
commit e72f82e983
101 changed files with 138 additions and 108 deletions
+1 -2
View File
@@ -8,8 +8,7 @@ module.exports = async (ctx) => {
method: 'get',
url: url,
});
const data = res.data;
const $ = cheerio.load(data);
const $ = cheerio.load(res.data);
const list = $('.news_list .list li')
.slice(0, 10)
.get();
+1 -1
View File
@@ -6,7 +6,7 @@ const ProcessFeed = (data) => {
const cover = $('meta[property="og:image"]');
if (cover.length > 0) {
$(`<img src=${cover[0].attribs.content}>`).insertBefore(content[0].firstChild);
$(`<img referrerpolicy="no-referrer" src=${cover[0].attribs.content}>`).insertBefore(content[0].firstChild);
}
// remove useless DOMs
+1 -1
View File
@@ -26,7 +26,7 @@ module.exports = async (ctx) => {
item = $(item);
return {
title: item.find('.img-scale').attr('title'),
description: item.find('p').text() + '<img src="' + item.find('img').attr('src') + '">',
description: item.find('p').text() + '<img referrerpolicy="no-referrer" src="' + item.find('img').attr('src') + '">',
pubDate: new Date(item.find('.time').text()).toUTCString(),
link: item.find('.img-scale').attr('href'),
};
+1 -1
View File
@@ -5,7 +5,7 @@ module.exports = async (ctx) => {
ctx.state.data = {
title: anime.title,
link: `https://ani.gamer.com.tw/animeRef.php?sn=${anime.anime_sn}`,
description: `<img src="${anime.cover}"> ` + anime.content.trim(),
description: `<img referrerpolicy="no-referrer" src="${anime.cover}"> ` + anime.content.trim(),
item: anime.volumes[0].map((item) => ({
title: `${anime.title} 第 ${item.volume} 集`,
link: `https://ani.gamer.com.tw/animeVideo.php?sn=${item.video_sn}`,
+1 -1
View File
@@ -14,7 +14,7 @@ module.exports = async (ctx) => {
img.searchParams.delete('w'); // get full resolution icon
ctx.state.data = {
title: $('.ver-top-h1').text(),
description: `<img src="${img.href}"> ` + $('.ver-top-title>h2').text(),
description: `<img referrerpolicy="no-referrer" src="${img.href}"> ` + $('.ver-top-title>h2').text(),
link: decodeURI(link),
item: $('.ver li')
.toArray()
+2 -6
View File
@@ -6,12 +6,8 @@ module.exports = async (ctx) => {
const country = ctx.params.country;
const url = `https://itunes.apple.com/${country}/app/${id}`;
const res = await axios({
method: 'get',
url,
});
const data = res.data;
const $ = cheerio.load(data);
const res = await axios.get(url);
const $ = cheerio.load(res.data);
const titleTags = $('h1').attr('class', 'product-header__title');
titleTags.find('span').remove();
+1 -1
View File
@@ -36,7 +36,7 @@ module.exports = async (ctx) => {
description: 'All the Flight Deals',
item: data.map((item) => ({
title: `[${item.dateRanges[0] ? dayjs(item.dateRanges[0].start).format('YYYY MMM DD') + ' to ' + dayjs(item.dateRanges[0].end).format('YYYY MMM DD') : ''}] ${item.title}`,
description: `<img src="https://alltheflightdeals.com/assets/cities/${item.cityPairs[0].destinationCity.id}.jpg" alt="${item.cityPairs[0].destination.city},${
description: `<img referrerpolicy="no-referrer" src="https://alltheflightdeals.com/assets/cities/${item.cityPairs[0].destinationCity.id}.jpg" alt="${item.cityPairs[0].destination.city},${
item.cityPairs[0].destination.countryName
}"> <br><table><tbody><tr><th align="left" style="border: 1px solid black;">From</th><th align="left" style="border: 1px solid black;">To</th><th align="left" style="border: 1px solid black;">Price</th></tr><tr><td style="border: 1px solid black;"><b>${
item.cityPairs[0].origin.iata
+1 -1
View File
@@ -49,7 +49,7 @@ module.exports = async (ctx) => {
let images = '';
$('.fpa-image-overlay img').each((i, e) => {
images += `<img src='${$(e).attr('data-src')}'/><br/>`;
images += `<img referrerpolicy="no-referrer" src='${$(e).attr('data-src')}'/><br/>`;
});
const description = keyFacts + images + $('meta[name="og:description"]').attr('content');
+1 -1
View File
@@ -33,7 +33,7 @@ module.exports = async (ctx) => {
updated.setMinutes(begin.getMinutes());
updated.setSeconds(begin.getSeconds());
const image = `<img src=${bgm.image} />`;
const image = `<img referrerpolicy="no-referrer" src=${bgm.image} />`;
const html =
image +
'<ul>' +
+1 -1
View File
@@ -17,7 +17,7 @@ module.exports = async (subjectID) => {
description: epsInfo.summary,
item: activeEps.reverse().map((e) => ({
title: `ep.${e.sort} ${e.name_cn}`,
description: `<img src="${epsInfo.images.common}" alt="ep.${e.sort} ${e.name_cn}"><p>${e.desc.replace(/\n+/g, '<br>')}</p>`,
description: `<img referrerpolicy="no-referrer" src="${epsInfo.images.common}" alt="ep.${e.sort} ${e.name_cn}"><p>${e.desc.replace(/\n+/g, '<br>')}</p>`,
pubDate: new Date(e.airdate).toUTCString(),
guid: e.id,
link: e.url,
+6 -3
View File
@@ -6,9 +6,12 @@ const ProcessImage = ($, e, c) => {
// handle cover image and lazy-loading images
if (img[0].attribs.src) {
message = `<figure><img alt='${img[0].attribs.alt ? img[0].attribs.alt : ''}' src='${img[0].attribs.src.replace(/(?<=\/news\/).*?(?=\/cpsprodpb)/, '600')}'><br><figcaption>`;
message = `<figure><img referrerpolicy="no-referrer" alt='${img[0].attribs.alt ? img[0].attribs.alt : ''}' src='${img[0].attribs.src.replace(/(?<=\/news\/).*?(?=\/cpsprodpb)/, '600')}'><br><figcaption>`;
} else {
message = `<figure><img alt='${img[0].attribs['data-alt'] ? img[0].attribs['data-alt'] : ''}' src='${img[0].attribs['data-src'].replace(/(?<=\/news\/).*?(?=\/cpsprodpb)/, '600')}'><br><figcaption>`;
message = `<figure><img referrerpolicy="no-referrer" alt='${img[0].attribs['data-alt'] ? img[0].attribs['data-alt'] : ''}' src='${img[0].attribs['data-src'].replace(
/(?<=\/news\/).*?(?=\/cpsprodpb)/,
'600'
)}'><br><figcaption>`;
}
// add image caption
@@ -94,7 +97,7 @@ const ProcessFeed = ($, link) => {
if (cover.length > 0) {
// there is a cover image
message = `<br><img src='${cover[0].attribs.src}'>` + message;
message = `<br><img referrerpolicy="no-referrer" src='${cover[0].attribs.src}'>` + message;
}
$(message).insertAfter(content[0].lastChild);
+1 -1
View File
@@ -20,7 +20,7 @@ module.exports = async (ctx) => {
const title = item.title;
const link = audio + item.statistic.sid;
const author = item.author;
const description = item.intro + `<br><img src="${item.cover}">`;
const description = item.intro + `<br><img referrerpolicy="no-referrer" src="${item.cover}">`;
const single = {
title: title,
+2 -4
View File
@@ -4,8 +4,7 @@ const axios = require('../../utils/axios');
module.exports = async (ctx) => {
const url = `http://www.bjnews.com.cn/${ctx.params.cat}`;
const res = await axios.get(url);
const data = res.data;
const $ = cheerio.load(data);
const $ = cheerio.load(res.data);
const list = $('#news_ul li').get();
const proList = [];
@@ -35,8 +34,7 @@ module.exports = async (ctx) => {
const responses = await axios.all(proList);
for (let i = 0; i < responses.length; i++) {
const res = responses[i];
const data = res.data;
const $ = cheerio.load(data);
const $ = cheerio.load(res.data);
out[indexList[i]].description = $('#main .content').html();
ctx.cache.set(out[indexList[i]].link, JSON.stringify(out[i]), 24 * 60 * 60);
}
+1 -2
View File
@@ -5,8 +5,7 @@ module.exports = async (ctx) => {
const { id } = ctx.params;
const url = `https://www.cyzone.cn/author/${id}`;
const res = await axios.get(url);
const data = res.data;
const $ = cheerio.load(data);
const $ = cheerio.load(res.data);
const list = $('.article-item');
+1 -1
View File
@@ -21,7 +21,7 @@ module.exports = async (ctx) => {
const d = await getArticle('https://mbasic.facebook.com' + url);
return {
title: d.title,
description: d.imgs.map((u) => `<img src="${u}">`).join('\n') + d.content.replace(/\n/g, '<br>'),
description: d.imgs.map((u) => `<img referrerpolicy="no-referrer" src="${u}">`).join('\n') + d.content.replace(/\n/g, '<br>'),
link: d.url,
};
})
+1 -1
View File
@@ -10,7 +10,7 @@ const ProcessFeed = ($, link) => {
content.find('div.story-image > figure').each((i, e) => {
const src = `https://www.ft.com/__origami/service/image/v2/images/raw/${encodeURIComponent(e.attribs['data-url'])}?source=ftchinese&width=800&fit=cover`;
$(`<img src=${src}>`).insertAfter(content.find('div.story-lead')[0]);
$(`<img referrerpolicy="no-referrer" src=${src}>`).insertAfter(content.find('div.story-lead')[0]);
});
// 付费文章跳转
+1 -1
View File
@@ -38,7 +38,7 @@ module.exports = async (ctx) => {
link: host,
item: data.map((follower) => ({
title: `${follower.node.login} started following ${user}`,
description: `<a href="https://github.com/${follower.node.login}">${follower.node.login}</a> <br> <img sytle="width:50px;" src='${follower.node.avatarUrl}'>`,
description: `<a href="https://github.com/${follower.node.login}">${follower.node.login}</a> <br> <img referrerpolicy="no-referrer" sytle="width:50px;" src='${follower.node.avatarUrl}'>`,
link: `https://github.com/${follower.node.login}`,
})),
};
+1 -1
View File
@@ -39,7 +39,7 @@ module.exports = async (ctx) => {
link: host,
item: data.map((follower) => ({
title: `${follower.node.login} starred ${user}/${repo}`,
description: `<a href="https://github.com/${follower.node.login}">${follower.node.login}</a> <br> <img sytle="width:50px;" src='${follower.node.avatarUrl}'>`,
description: `<a href="https://github.com/${follower.node.login}">${follower.node.login}</a> <br> <img referrerpolicy="no-referrer" sytle="width:50px;" src='${follower.node.avatarUrl}'>`,
link: `https://github.com/${follower.node.login}`,
})),
};
+1 -2
View File
@@ -13,8 +13,7 @@ module.exports = async (ctx) => {
method: 'get',
url: `https://gitlab.com/explore/projects/${type}`,
});
const data = res.data;
const $ = cheerio.load(data);
const $ = cheerio.load(res.data);
const list = $('ul.projects-list').find('li');
ctx.state.data = {
+1 -1
View File
@@ -26,7 +26,7 @@ module.exports = async (ctx) => {
item = $(item);
return {
title: item.find('.GN-lbox2D').text(),
description: item.find('.GN-lbox2C').text() + '<img src="' + item.find('.GN-lbox2E img').attr('src') + '">',
description: item.find('.GN-lbox2C').text() + '<img referrerpolicy="no-referrer" src="' + item.find('.GN-lbox2E img').attr('src') + '">',
pubDate: new Date(item.find('.time').data('shared-at')).toUTCString(),
link: item.find('.GN-lbox2D a').attr('href'),
};
+1 -2
View File
@@ -15,8 +15,7 @@ module.exports = async (ctx) => {
sort: 'updated',
},
});
const data = res.data;
const $ = cheerio.load(data);
const $ = cheerio.load(res.data);
const list = $('.script-list').find('h2');
ctx.state.data = {
+2 -2
View File
@@ -11,7 +11,7 @@ const ProcessFeed = (data) => {
content.find('.element-image').each((i, e) => {
const pic = $(e).find('img');
let rpic = `<figure><img alt='${pic[0].attribs.alt}' src='${pic[0].attribs.src}'><br><figcaption>`;
let rpic = `<figure><img referrerpolicy="no-referrer" alt='${pic[0].attribs.alt}' src='${pic[0].attribs.src}'><br><figcaption>`;
const rcaption = $(e).find('figcaption');
rpic += `${$(rcaption[0])
.text()
@@ -23,7 +23,7 @@ const ProcessFeed = (data) => {
// there is a cover photo
const photo = $('#img-1').find('img');
let cover = `<figure><img alt='${photo[0].attribs.alt}' src='${photo[0].attribs.src}'><br><figcaption>`;
let cover = `<figure><img referrerpolicy="no-referrer" alt='${photo[0].attribs.alt}' src='${photo[0].attribs.src}'><br><figcaption>`;
const caption = $('#img-1').find('figcaption');
+1 -2
View File
@@ -4,8 +4,7 @@ const axios = require('../../utils/axios');
module.exports = async (ctx) => {
const url = `http://${ctx.params.url}`;
const res = await axios.get(`${url}/archives`);
const data = res.data;
const $ = cheerio.load(data);
const $ = cheerio.load(res.data);
const list = $('.post-header');
+1 -2
View File
@@ -4,8 +4,7 @@ const axios = require('../../utils/axios');
module.exports = async (ctx) => {
const url = `http://${ctx.params.url}`;
const res = await axios.get(url);
const data = res.data;
const $ = cheerio.load(data);
const $ = cheerio.load(res.data);
const authorInfo = $('.left-col').find('#header');
const title = authorInfo.find('.header-author').text();
const subtitle = authorInfo.find('.header-subtitle').text();
+1 -2
View File
@@ -4,8 +4,7 @@ const cheerio = require('cheerio');
module.exports = async (ctx) => {
const baseUrl = `https://houxu.app/events`;
const res = await axios.get(baseUrl);
const data = res.data;
const $ = cheerio.load(data);
const $ = cheerio.load(res.data);
const list = $('div.list > div');
const descriptionSelector = '.summary';
+1 -2
View File
@@ -6,8 +6,7 @@ module.exports = async (ctx) => {
const filter = timeline ? timeline : 'all';
const baseUrl = `https://houxu.app/lives/${id}?filter=${filter}`;
const res = await axios.get(baseUrl);
const data = res.data;
const $ = cheerio.load(data);
const $ = cheerio.load(res.data);
const list = $('section.threads > div');
const out = list
+1 -2
View File
@@ -5,8 +5,7 @@ module.exports = async (ctx) => {
const { type } = ctx.params;
const baseUrl = `https://houxu.app/lives/${type}`;
const res = await axios.get(baseUrl);
const data = res.data;
const $ = cheerio.load(data);
const $ = cheerio.load(res.data);
const list = $('div.list > div');
const out = list
+1 -1
View File
@@ -17,7 +17,7 @@ module.exports = async (ctx) => {
if ($(e).find('figcaption').length > 0) {
const caption = $($(e).find('figcaption')[0]).html();
media = `<figure><img src=${$(media).attr('src')}><figcaption>${caption}</figcaption></figure>`;
media = `<figure><img referrerpolicy="no-referrer" src=${$(media).attr('src')}><figcaption>${caption}</figcaption></figure>`;
}
$(media).insertAfter(e);
+1 -1
View File
@@ -22,7 +22,7 @@ module.exports = async (ctx) => {
item = $(item);
return {
title: item.find('h4').text(),
description: item.find('p').text() + '<img src="' + item.find('img').attr('src') + '">',
description: item.find('p').text() + '<img referrerpolicy="no-referrer" src="' + item.find('img').attr('src') + '">',
link:
'https://www.indienova.com' +
item
+4 -2
View File
@@ -94,7 +94,7 @@ module.exports = {
if (item.pictures) {
item.pictures.forEach((pic) => {
if (pic.format === 'gif') {
description += `<img src="${pic.picUrl.split('?imageMogr2/')[0]}"></picture>`;
description += `<img referrerpolicy="no-referrer" src="${pic.picUrl.split('?imageMogr2/')[0]}"></picture>`;
} else {
// jpeg, bmp, png, gif, webp
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types
@@ -110,7 +110,9 @@ module.exports = {
break;
}
const imgUrl = pic.picUrl.match(/\.[a-z0-9]+?\?imageMogr2/) ? pic.picUrl.split('?imageMogr2/')[0] : pic.picUrl.replace(/thumbnail\/.+/, '');
description += `<br/><picture><source srcset="${pic.picUrl.split('/thumbnail/')[0]}/strip/format/webp" type="image/webp"><source srcset="${imgUrl}" type="image/${type}"><img src="${imgUrl}"></picture>`;
description += `<br/><picture><source srcset="${
pic.picUrl.split('/thumbnail/')[0]
}/strip/format/webp" type="image/webp"><source srcset="${imgUrl}" type="image/${type}"><img referrerpolicy="no-referrer" src="${imgUrl}"></picture>`;
}
});
}
+1 -1
View File
@@ -10,7 +10,7 @@ module.exports = async (ctx) => {
link: 'https://kirarafantasia.com/news/',
description: '「まんがタイムきらら」の人気キャラクターたちが、RPGの世界に大集合!あなたの毎日が「きらら」でいっぱいに! #きらファン',
item: posts.map((post) => {
const image = `<img src=${post.thumbnail} />`;
const image = `<img referrerpolicy="no-referrer" src=${post.thumbnail} />`;
const html = image;
+1 -2
View File
@@ -13,8 +13,7 @@ module.exports = async (ctx) => {
tid: id,
},
});
const data = res.data;
const $ = cheerio.load(data);
const $ = cheerio.load(res.data);
const list = $('tbody').find('td');
ctx.state.data = {
+1 -1
View File
@@ -16,7 +16,7 @@ const ProcessFeed = async (list) => {
// RSS内容(美拍提供了友好的网页版视频展示)
const imgSrc = $('.feed-v-wrap img').attr('src');
const text = $desciption.text() + `<a href="${itemUrl}"><img src="https:${imgSrc}" /></a>`;
const text = $desciption.text() + `<a href="${itemUrl}"><img referrerpolicy="no-referrer" src="https:${imgSrc}" /></a>`;
// 列表上提取到的信息
return {
+1 -2
View File
@@ -5,8 +5,7 @@ module.exports = async (ctx) => {
const type = `${ctx.params.type ? ctx.params.type : ''}`;
const url = `https://www.natgeomedia.com/category/${ctx.params.cat}/${type}`;
const res = await axios.get(url);
const data = res.data;
const $ = cheerio.load(data);
const $ = cheerio.load(res.data);
const list = $('.td-ss-main-content').find('.td-animation-stack');
+1 -1
View File
@@ -34,7 +34,7 @@ module.exports = async (ctx) => {
itunes_author: dj.nickname,
itunes_category: radio.category,
item: programs.map((pg) => {
const image = `<img src=${pg.coverUrl} />`;
const image = `<img referrerpolicy="no-referrer" src=${pg.coverUrl} />`;
const description = `<div>${(pg.description || '')
.split('\n')
+1 -1
View File
@@ -33,7 +33,7 @@ module.exports = async (ctx) => {
updated: response.headers.date,
icon: avatarUrl,
item: playlist.map((pl) => {
const image = `<img src=${pl.coverImgUrl} />`;
const image = `<img referrerpolicy="no-referrer" src=${pl.coverImgUrl} />`;
const description = `<div>${(pl.description || '')
.split('\n')
+1 -1
View File
@@ -29,7 +29,7 @@ module.exports = async (ctx) => {
const eraseTag = (str) => str.replace(/\[(\w+)\].+?\[\/\1\]/g, '');
const eraseQuote = (str) => str.replace(/\[quote\](.+?)\[\/quote\]/, (m, b) => b).replace(/\[b\].*?\[uid=\d+\](.+?)\[\/uid\].+?\[\/b\]/, (m, user) => `@${user} `);
const pipeImg = (str) => str.replace(/\[img\](.+?)\[\/img\]/g, (m, src) => `<img src='${src[0] === '.' ? 'https://img.nga.178.com/attachments' + src.substr(1) : src}'></img>`);
const pipeImg = (str) => str.replace(/\[img\](.+?)\[\/img\]/g, (m, src) => `<img referrerpolicy="no-referrer" src='${src[0] === '.' ? 'https://img.nga.178.com/attachments' + src.substr(1) : src}'></img>`);
const tid = ctx.params.tid;
const pageId = await getLastPageId(tid);
+1 -2
View File
@@ -9,8 +9,7 @@ module.exports = async (ctx) => {
Referer: 'https://www.oschina.net/news/',
},
});
const data = res.data;
const $ = cheerio.load(data);
const $ = cheerio.load(res.data);
const list = $('#newsList').find('.news-item');
const count = [];
for (let i = 0; i < Math.min(list.length, 10); i++) {
+1 -1
View File
@@ -26,7 +26,7 @@ module.exports = async (ctx) => {
item = $(item);
return {
title: item.find('.intro h2 a').attr('title'),
description: item.find('.brief').text() + '<img src="' + item.find('.movie-thumbnails .pure-img').attr('data-original') + '">',
description: item.find('.brief').text() + '<img referrerpolicy="no-referrer" src="' + item.find('.movie-thumbnails .pure-img').attr('data-original') + '">',
pubDate: new Date(item.find('.time').data('shared-at')).toUTCString(),
link: item.find('.intro h2 a').attr('href'),
};
+1 -2
View File
@@ -8,8 +8,7 @@ module.exports = async (ctx) => {
method: 'get',
url: url,
});
const data = res.data;
const $ = cheerio.load(data);
const $ = cheerio.load(res.data);
const resultItem = [];
$('.J-mainDetail #docArticleContent h3').each(function() {
+1 -2
View File
@@ -13,8 +13,7 @@ module.exports = {
const res = await axios_ins.get(link);
const data = res.data;
const $ = cheerio.load(data);
const $ = cheerio.load(res.data);
const list = $('p.news_tit01, div.news_tit02')
.slice(0, 10)
.get();
+3 -1
View File
@@ -54,7 +54,9 @@ module.exports = async (ctx) => {
const data = response.data;
const $ = cheerio.load(data);
const list = $('.mainleft > .listlefttop > .listleftop1').get();
const list = $('.mainleft > .listlefttop > .listleftop1')
.splice(0, 10)
.get();
const result = await util.ProcessFeed(list, ctx.cache);
+1
View File
@@ -24,6 +24,7 @@ module.exports = async (ctx) => {
link: pageUrl,
title: category === 'all' ? baseTitle : `${baseTitle} ${$('title').text()}`,
item: $('div[id^="wp_news_w"] a')
.splice(0, 10)
.filter((_, elem) => elem.attribs.href.match(entryUrlRegex))
.map((_, elem) => ({
link: url.resolve(pageUrl, elem.attribs.href),
+1
View File
@@ -24,6 +24,7 @@ module.exports = async (ctx) => {
link: pageUrl,
title: category === 'all' ? baseTitle : `${baseTitle} ${$('title').text()}`,
item: $('div[id^="wp_news_w"] a')
.splice(0, 10)
.filter((_, elem) => elem.attribs.href.match(entryUrlRegex))
.map((_, elem) => ({
link: url.resolve(pageUrl, elem.attribs.href),
+1 -1
View File
@@ -13,7 +13,7 @@ module.exports = async (ctx) => {
const link = host + map[type];
const response = await axios.get(link);
const $ = cheerio.load(response.data);
const list = $('li[id^="lineu"]');
const list = $('li[id^="lineu"]').splice(0, 10);
ctx.state.data = {
title: '重科教务处',
+3 -1
View File
@@ -16,7 +16,9 @@ module.exports = async (ctx) => {
},
});
const $ = cheerio.load(response.data);
const list = $('div[class="newsList"]').find('li');
const list = $('div[class="newsList"]')
.find('li')
.splice(0, 10);
ctx.state.data = {
title: '重科图书馆',
+3 -1
View File
@@ -30,7 +30,9 @@ module.exports = async (ctx) => {
});
const $ = cheerio.load(response.data);
const text = $('div.con-right').find('div.list_div');
const text = $('div.con-right')
.find('div.list_div')
.splice(0, 10);
ctx.state.data = {
title: `东莞理工学院 ${name} ${info}`,
+3 -1
View File
@@ -33,7 +33,9 @@ module.exports = async (ctx) => {
});
const $ = cheerio.load(response.data);
const text = $('#paging > ul').find('li');
const text = $('#paging > ul')
.find('li')
.splice(0, 10);
ctx.state.data = {
title: `东莞理工学院 ${name} ${info}`,
@@ -31,6 +31,7 @@ module.exports = async (ctx) => {
link: base_url,
title: '大连大学教务处',
item: $('td[valign="top"]>table[cellspacing="3"][width="100%"] tr')
.splice(0, 10)
.map((_, elem) => ({
link: resolve_url(base_url, $('a', elem).attr('href')),
title: $('a', elem).attr('title'),
@@ -30,6 +30,7 @@ module.exports = async (ctx) => {
link: link,
title: $('#more>h1').text(),
item: $('.more_list>li')
.splice(0, 10)
.map((_, elem) => ({
link: resolve_url(base_url, $('a', elem).attr('href')),
title: $('a', elem).text(),
+1
View File
@@ -29,6 +29,7 @@ module.exports = async (ctx) => {
link: link,
title: $('#more>h1').text(),
item: $('.more_list>li')
.splice(0, 10)
.map((_, elem) => ({
link: resolve_url(base_url, $('a', elem).attr('href')),
title: $('a', elem).text(),
+1
View File
@@ -28,6 +28,7 @@ module.exports = async (ctx) => {
link: link,
title: $('title').text(),
item: $('.list>tr')
.splice(0, 10)
.map((_, elem) => ({
link: resolve_url(link, $('a', elem).attr('href')),
title: $('tit1', elem).text(),
+1
View File
@@ -11,6 +11,7 @@ module.exports = async (ctx) => {
const { data } = response;
const $ = cheerio.load(data);
const links = $('.news_list li')
.splice(0, 10)
.map((i, el) => ({
pubDate: new Date(
$('span.fbll', el)
+1
View File
@@ -16,6 +16,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data);
const category_name = $('div.banner-title').text();
const list = $('.paragraph li')
.splice(0, 10)
.map((i, e) => ({
path: $('span span a', e).attr('href'),
title: $('span span a', e).text(),
+1 -1
View File
@@ -6,7 +6,7 @@ module.exports = async (ctx) => {
const link = 'http://auto.hust.edu.cn/yxxw.htm';
const response = await axios.get(link);
const $ = cheerio.load(response.data);
const list = $('.N02_list li dl');
const list = $('.N02_list li dl').splice(0, 10);
ctx.state.data = {
title: '华科自动化学院新闻',
+2 -1
View File
@@ -11,7 +11,8 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data);
const list = $('.m_content .m_con')
.eq(type)
.find('.N02_list_dl');
.find('.N02_list_dl')
.splice(0, 10);
ctx.state.data = {
title: `华科自动化学院${typelist[type]}通知`,
+1 -1
View File
@@ -44,7 +44,7 @@ module.exports = async (ctx) => {
link: link,
title: $('title').text(),
item: $('.pg-list>ul>li')
.slice(0, 35)
.slice(0, 10)
.map((_, elem) => ({
link: resolve_url(link, $('a', elem).attr('href')),
title: $('a', elem).text(),
+1 -1
View File
@@ -21,7 +21,7 @@ module.exports = async (ctx) => {
link: url.resolve(baseUrl, `/module/careers${type === 'outer' && '?type=outer'}`),
item:
data.data &&
data.data.map((item) => {
data.data.splice(0, 10).map((item) => {
const { meet_day = '', meet_time = '', company_name = '', school_name = '', address = '', company_property = '', industry_category = '', career_talk_id = '' } = item;
return {
title: `【${meet_day} ${meet_time}】${company_name}`,
@@ -20,7 +20,7 @@ module.exports = async (ctx) => {
link: url.resolve(baseUrl, '/module/jobfairs'),
item:
data.data &&
data.data.map((item) => {
data.data.splice(0, 10).map((item) => {
const { meet_day = '', meet_time = '', title = '', school_name = '', address = '', fair_id = '' } = item;
return {
title: `【${meet_day} ${meet_time}】${title}`,
+1
View File
@@ -33,6 +33,7 @@ module.exports = async (ctx) => {
link: pageUrl,
title,
item: $('table[width="92%"] a[target="_blank"]')
.splice(0, 10)
.map((_, elem) => ({
link: url.resolve(baseUrl, elem.attribs.href),
title: elem.children[0].data,
+1
View File
@@ -25,6 +25,7 @@ module.exports = async (ctx) => {
const linkList = $('td[width=515]')
.find('a')
.splice(0, 10)
.map((_, e) => ({
title: $(e).text(),
link: `${host}/${$(e).attr('href')}`,
@@ -15,6 +15,7 @@ module.exports = async (ctx) => {
const id = map.get(type).id;
const items = $(`#${id} tr tr`)
.splice(0, 10)
.map((_, elem) => {
const a = $('td:first-child > a', elem);
return {
+2 -5
View File
@@ -14,15 +14,12 @@ module.exports = async (ctx) => {
Referer: 'https://gs.njust.edu.cn/',
},
});
const data = res.data;
const $ = cheerio.load(data);
const list = $('.wp_article_list li');
const $ = cheerio.load(res.data);
const list = $('.wp_article_list li').splice(0, 10);
ctx.state.data = {
title: map.get(type).title,
link: 'https://gs.njust.edu.cn',
// description: '',
item:
list &&
list
@@ -20,6 +20,7 @@ module.exports = async (ctx) => {
const id = map.get(type).id;
const items = $(`#${id} tr tr`)
.splice(0, 10)
.map((_, elem) => {
const a = $('td:first-child > a', elem);
return {
+1 -1
View File
@@ -23,7 +23,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data);
const list = $('#wp_news_w6 ul li');
const list = $('#wp_news_w6 ul li').splice(0, 10);
ctx.state.data = {
title: '南开大学教务处',
+3 -1
View File
@@ -27,7 +27,9 @@ module.exports = async (ctx) => {
const response = await axios.get(link);
const $ = cheerio.load(response.data);
const list = $('.news_list').find('.news');
const list = $('.news_list')
.find('.news')
.splice(0, 10);
ctx.state.data = {
title: baseTitle + (category === '791' ? '' : ':' + map[category]),
+3 -1
View File
@@ -23,7 +23,9 @@ module.exports = async (ctx) => {
.find('tr.gridline')
.slice(0, 6)
.map((index, item) => {
const td = $(item).find('td.gridline');
const td = $(item)
.find('td.gridline')
.splice(0, 10);
return {
title: $(item)
.find('.Title')
+1 -1
View File
@@ -18,7 +18,7 @@ module.exports = async (ctx) => {
});
const $ = cheerio.load(response.data);
const text = $('.hvr-shutter-out-vertical');
const text = $('.hvr-shutter-out-vertical').splice(0, 10);
ctx.state.data = {
title: '北大信科通知',
+1 -2
View File
@@ -9,8 +9,7 @@ module.exports = async (ctx) => {
Referer: 'https://cs.scnu.edu.cn',
},
});
const data = res.data;
const $ = cheerio.load(data);
const $ = cheerio.load(res.data);
const list = $('.listshow')
.find('li')
.not('li.line');
+4 -3
View File
@@ -9,9 +9,10 @@ module.exports = async (ctx) => {
Referer: 'https://jw.scnu.edu.cn',
},
});
const data = res.data;
const $ = cheerio.load(data);
const list = $('.notice_01').find('li');
const $ = cheerio.load(res.data);
const list = $('.notice_01')
.find('li')
.splice(0, 10);
ctx.state.data = {
title: $('title')
+4 -3
View File
@@ -9,9 +9,10 @@ module.exports = async (ctx) => {
Referer: 'https://lib.scnu.edu.cn',
},
});
const data = res.data;
const $ = cheerio.load(data);
const list = $('.article-list').find('li');
const $ = cheerio.load(res.data);
const list = $('.article-list')
.find('li')
.splice(0, 10);
ctx.state.data = {
title: $('title').text(),
@@ -21,7 +21,7 @@ module.exports = async (ctx) => {
const $ = formal(response.data);
const list = $('.data');
const list = $('.data').splice(0, 10);
ctx.state.data = {
title: '四川旅游学院',
@@ -16,7 +16,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(data);
const list = $('.list_dt a');
const list = $('.list_dt a').splice(0, 10);
ctx.state.data = {
title: '四川旅游学院信息与工程系',
+1 -1
View File
@@ -21,7 +21,7 @@ module.exports = async (ctx) => {
const $ = formal(response.data);
const list = $('#list2');
const list = $('#list2').splice(0, 10);
ctx.state.data = {
title: '四川旅游学院信息与工程学院',
+1 -1
View File
@@ -22,7 +22,7 @@ module.exports = async (ctx) => {
const $ = formal(response.data);
const list = $('#list1 ul li');
const list = $('#list1 ul li').splice(0, 10);
ctx.state.data = {
title: '四川旅游学院',
+1 -1
View File
@@ -31,7 +31,7 @@ module.exports = async (ctx) => {
}),
});
const itemList = listResponse.data.results;
const itemList = listResponse.data.results.splice(0, 10);
const out = await Promise.all(
itemList.map(async (itemData) => {
const itemUrl = url.resolve(baseUrl, 'jiaowuchu' + itemData.href);
+1
View File
@@ -14,6 +14,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data);
const list = $('#list_right_list a')
.splice(0, 10)
.map((i, e) => $(e).attr('href'))
.get();
+1
View File
@@ -14,6 +14,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data);
const list = $('#page_right_main li a')
.splice(0, 10)
.map((i, e) => $(e).attr('href'))
.get();
@@ -11,6 +11,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data);
const list = $('#div_more_news a')
.splice(0, 10)
.map((i, e) => $(e).attr('href'))
.get();
+1
View File
@@ -14,6 +14,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data);
const list = $('#page_list li a')
.splice(0, 10)
.map((i, e) => $(e).attr('href'))
.get();
+1
View File
@@ -15,6 +15,7 @@ module.exports = async (ctx) => {
const dateDict = {};
const list = $('#div_more_news .leftNews')
.splice(0, 10)
.map((i, e) => {
const divs = $(e).children();
let c_link = $('a', divs[1]).attr('href');
+1
View File
@@ -19,6 +19,7 @@ module.exports = async (ctx) => {
const id = map.get(type).id;
const items = $(`#${id} tr tr`)
.splice(0, 10)
.map((_, elem) => {
const a = $('td:first-child > a', elem);
return {
+1 -1
View File
@@ -13,7 +13,7 @@ module.exports = async (ctx) => {
});
const $ = cheerio.load(response.data);
const text = $('tr', 'tbody');
const text = $('tr', 'tbody').splice(0, 10);
ctx.state.data = {
title: '上海海事大学 学术讲座',
+1 -1
View File
@@ -20,7 +20,7 @@ module.exports = async (ctx) => {
});
const $ = cheerio.load(response.data);
const text = $('.gvRow', '.tdMCViewList');
const text = $('.gvRow', '.tdMCViewList').splice(0, 10);
ctx.state.data = {
title: `上海海事大学 ${info}`,
+1 -1
View File
@@ -13,7 +13,7 @@ module.exports = async (ctx) => {
});
const $ = cheerio.load(response.data);
const text = $('tr', 'tbody');
const text = $('tr', 'tbody').splice(0, 10);
ctx.state.data = {
title: '上海海事大学 通知公告',
+1
View File
@@ -25,6 +25,7 @@ module.exports = async (ctx) => {
const respond = await axios.get(link);
const $ = cheerio.load(respond.data);
const list = $('#dnn_ctr43516_ArticleList__ctl0_ArtDataList__ctl1_titleLink1')
.splice(0, 10)
.map(function(index, ele) {
return {
title: $(ele).attr('title'),
+3 -1
View File
@@ -19,7 +19,9 @@ module.exports = async (ctx) => {
const data = response.data;
const $ = cheerio.load(data);
const list = $('.comm li').get();
const list = $('.comm li')
.splice(0, 10)
.get();
const result = await util.ProcessFeed(list, ctx.cache, url);
@@ -11,6 +11,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data);
const list = $('.list_style_1 li a')
.splice(0, 10)
.map((i, e) => $(e).attr('href'))
.get();
@@ -11,6 +11,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data);
const list = $('.list_box_5 li')
.splice(0, 10)
.map((i, e) => ({
date: $(e)
.children('span')
@@ -11,6 +11,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data);
const list = $('.list_box_5 li')
.splice(0, 10)
.map((i, e) => ({
date: $(e)
.children('span')
@@ -11,6 +11,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data);
const list = $('.list_box_5 li')
.splice(0, 10)
.map((i, e) => ({
date: $(e)
.children('span')
@@ -11,6 +11,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data);
const list = $('.list_box_5 li')
.splice(0, 10)
.map((i, e) => ({
date: $(e)
.children('span')
@@ -11,6 +11,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data);
const list = $('.list_box_5 li')
.splice(0, 10)
.map((i, e) => ({
date: $(e)
.children('span')
@@ -39,6 +39,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data);
const list = $('.list_box_5_2 li')
.splice(0, 10)
.map((i, e) => ({
date: $(e)
.children('span')
+1
View File
@@ -9,6 +9,7 @@ module.exports = async (ctx) => {
const $ = load(data);
const urls = $('.view-content li > a')
.splice(0, 10)
.map((_, ele) => $(ele).attr('href'))
.toArray()
.map((path) => path.match(/\/content\/(\d+)/)[1]) // extract article-id
+3 -1
View File
@@ -22,7 +22,9 @@ module.exports = async (ctx) => {
// get urls
const detail_urls = [];
const a = $('ul.data-list').find('a');
const a = $('ul.data-list')
.find('a')
.splice(0, 10);
for (let i = 0; i < a.length; ++i) {
const tmp = $(a[i]).attr('href');
+1
View File
@@ -27,6 +27,7 @@ module.exports = async (ctx) => {
title: '电子科技大学教务处通知公告',
link: baseUrl,
item: $('div[class="textAreo clearfix"] a')
.splice(0, 10)
.map((_, elem) => ({
link: detailUrl + elem.attribs.newsid,
title: elem.attribs.title,
+1
View File
@@ -22,6 +22,7 @@ module.exports = async (ctx) => {
title: '电子科技大学新闻中心',
link: baseUrl,
item: $('div[id="Degas_news_list"] ul li h3 a')
.splice(0, 10)
.map((_, elem) => ({
link: baseUrl + elem.attribs.href,
title: $(elem).text(),
+2 -2
View File
@@ -4,7 +4,7 @@ const cheerio = require('cheerio');
const host = 'http://www.wzbc.edu.cn';
const parserAbb = ($) => {
const items = $('.newslist li');
const items = $('.newslist li').splice(0, 10);
return {
title: $('title').text(),
item:
@@ -24,7 +24,7 @@ const parserAbb = ($) => {
};
const parserFull = ($) => {
const items = $('.picnewlist li');
const items = $('.picnewlist li').splice(0, 10);
return {
title: $('title').text(),
item:
+1
View File
@@ -19,6 +19,7 @@ module.exports = async (ctx) => {
list = list
.filter((index) => index % 2 !== 0)
.splice(0, 10)
.map((index, item) => {
this.index = index;
item = $(item);

Some files were not shown because too many files have changed in this diff Show More