fix splice

This commit is contained in:
DIYgod 2019-03-13 12:45:24 +08:00
parent 7c72d91b1b
commit af1df7f178
No known key found for this signature in database
GPG Key ID: EC0B76A252D3EF67
56 changed files with 57 additions and 57 deletions

View File

@ -53,7 +53,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data);
const list = $('.mainleft > .listlefttop > .listleftop1').splice(0, 10);
const list = $('.mainleft > .listlefttop > .listleftop1').slice(0, 10);
const result = await util.ProcessFeed(list, ctx.cache);

View File

@ -24,7 +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)
.slice(0, 10)
.filter((_, elem) => elem.attribs.href.match(entryUrlRegex))
.map((_, elem) => ({
link: url.resolve(pageUrl, elem.attribs.href),

View File

@ -24,7 +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)
.slice(0, 10)
.filter((_, elem) => elem.attribs.href.match(entryUrlRegex))
.map((_, elem) => ({
link: url.resolve(pageUrl, elem.attribs.href),

View File

@ -15,7 +15,7 @@ module.exports = async (ctx) => {
const data = response.data;
const $ = cheerio.load(data);
const $list = $('div#wp_news_w3 a').splice(0, 10);
const $list = $('div#wp_news_w3 a').slice(0, 10);
const resultItem = await Promise.all(
$list.map(async (item) => {

View File

@ -15,7 +15,7 @@ module.exports = async (ctx) => {
const data = response.data;
const $ = cheerio.load(data);
const $list = $('div#wp_news_w6 ul.news_list li a').splice(0, 10);
const $list = $('div#wp_news_w6 ul.news_list li a').slice(0, 10);
const resultItem = await Promise.all(
$list.map(async (item) => {

View File

@ -15,7 +15,7 @@ module.exports = async (ctx) => {
const data = response.data;
const $ = cheerio.load(data);
const $list = $('div.listbox tbody td a').splice(0, 10);
const $list = $('div.listbox tbody td a').slice(0, 10);
const resultItem = await Promise.all(
$list.map(async (item) => {

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"]').splice(0, 10);
const list = $('li[id^="lineu"]').slice(0, 10);
ctx.state.data = {
title: '重科教务处',

View File

@ -18,7 +18,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data);
const list = $('div[class="newsList"]')
.find('li')
.splice(0, 10);
.slice(0, 10);
ctx.state.data = {
title: '重科图书馆',

View File

@ -32,7 +32,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data);
const text = $('div.con-right')
.find('div.list_div')
.splice(0, 10);
.slice(0, 10);
ctx.state.data = {
title: `东莞理工学院 ${name} ${info}`,

View File

@ -35,7 +35,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data);
const text = $('#paging > ul')
.find('li')
.splice(0, 10);
.slice(0, 10);
ctx.state.data = {
title: `东莞理工学院 ${name} ${info}`,

View File

@ -31,7 +31,7 @@ module.exports = async (ctx) => {
link: base_url,
title: '大连大学教务处',
item: $('td[valign="top"]>table[cellspacing="3"][width="100%"] tr')
.splice(0, 10)
.slice(0, 10)
.map((_, elem) => ({
link: resolve_url(base_url, $('a', elem).attr('href')),
title: $('a', elem).attr('title'),

View File

@ -30,7 +30,7 @@ module.exports = async (ctx) => {
link: link,
title: $('#more>h1').text(),
item: $('.more_list>li')
.splice(0, 10)
.slice(0, 10)
.map((_, elem) => ({
link: resolve_url(base_url, $('a', elem).attr('href')),
title: $('a', elem).text(),

View File

@ -29,7 +29,7 @@ module.exports = async (ctx) => {
link: link,
title: $('#more>h1').text(),
item: $('.more_list>li')
.splice(0, 10)
.slice(0, 10)
.map((_, elem) => ({
link: resolve_url(base_url, $('a', elem).attr('href')),
title: $('a', elem).text(),

View File

@ -28,7 +28,7 @@ module.exports = async (ctx) => {
link: link,
title: $('title').text(),
item: $('.list>tr')
.splice(0, 10)
.slice(0, 10)
.map((_, elem) => ({
link: resolve_url(link, $('a', elem).attr('href')),
title: $('tit1', elem).text(),

View File

@ -6,7 +6,7 @@ module.exports = async (ctx) => {
const link = 'http://aia.hust.edu.cn/yxxw.htm';
const response = await axios.get(link);
const $ = cheerio.load(response.data);
const list = $('.N02_list li dl').splice(0, 10);
const list = $('.N02_list li dl').slice(0, 10);
ctx.state.data = {
title: '华科人工智能和自动化学院新闻',

View File

@ -12,7 +12,7 @@ module.exports = async (ctx) => {
const list = $('.m_content .m_con')
.eq(type)
.find('.N02_list_dl')
.splice(0, 10);
.slice(0, 10);
ctx.state.data = {
title: `华科人工智能和自动化学院${typelist[type]}通知`,

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.splice(0, 10).map((item) => {
data.data.slice(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}`,

View File

@ -20,7 +20,7 @@ module.exports = async (ctx) => {
link: url.resolve(baseUrl, '/module/jobfairs'),
item:
data.data &&
data.data.splice(0, 10).map((item) => {
data.data.slice(0, 10).map((item) => {
const { meet_day = '', meet_time = '', title = '', school_name = '', address = '', fair_id = '' } = item;
return {
title: `${meet_day} ${meet_time}${title}`,

View File

@ -33,7 +33,7 @@ module.exports = async (ctx) => {
link: pageUrl,
title,
item: $('table[width="92%"] a[target="_blank"]')
.splice(0, 10)
.slice(0, 10)
.map((_, elem) => ({
link: url.resolve(baseUrl, elem.attribs.href),
title: elem.children[0].data,

View File

@ -25,7 +25,7 @@ module.exports = async (ctx) => {
const linkList = $('td[width=515]')
.find('a')
.splice(0, 10)
.slice(0, 10)
.map((_, e) => ({
title: $(e).text(),
link: `${host}/${$(e).attr('href')}`,

View File

@ -15,7 +15,7 @@ module.exports = async (ctx) => {
const id = map.get(type).id;
const items = $(`#${id} tr tr`)
.splice(0, 10)
.slice(0, 10)
.map((_, elem) => {
const a = $('td:first-child > a', elem);
return {

View File

@ -15,7 +15,7 @@ module.exports = async (ctx) => {
},
});
const $ = cheerio.load(res.data);
const list = $('.wp_article_list li').splice(0, 10);
const list = $('.wp_article_list li').slice(0, 10);
ctx.state.data = {
title: map.get(type).title,

View File

@ -20,7 +20,7 @@ module.exports = async (ctx) => {
const id = map.get(type).id;
const items = $(`#${id} tr tr`)
.splice(0, 10)
.slice(0, 10)
.map((_, elem) => {
const a = $('td:first-child > a', elem);
return {

View File

@ -23,7 +23,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data);
const list = $('#wp_news_w6 ul li').splice(0, 10);
const list = $('#wp_news_w6 ul li').slice(0, 10);
ctx.state.data = {
title: '南开大学教务处',

View File

@ -29,7 +29,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data);
const list = $('.news_list')
.find('.news')
.splice(0, 10);
.slice(0, 10);
ctx.state.data = {
title: baseTitle + (category === '791' ? '' : ':' + map[category]),

View File

@ -25,7 +25,7 @@ module.exports = async (ctx) => {
.map((index, item) => {
const td = $(item)
.find('td.gridline')
.splice(0, 10);
.slice(0, 10);
return {
title: $(item)
.find('.Title')

View File

@ -18,7 +18,7 @@ module.exports = async (ctx) => {
});
const $ = cheerio.load(response.data);
const text = $('.hvr-shutter-out-vertical').splice(0, 10);
const text = $('.hvr-shutter-out-vertical').slice(0, 10);
ctx.state.data = {
title: '北大信科通知',

View File

@ -12,7 +12,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(res.data);
const list = $('.notice_01')
.find('li')
.splice(0, 10);
.slice(0, 10);
ctx.state.data = {
title: $('title')

View File

@ -12,7 +12,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(res.data);
const list = $('.article-list')
.find('li')
.splice(0, 10);
.slice(0, 10);
ctx.state.data = {
title: $('title').text(),

View File

@ -21,7 +21,7 @@ module.exports = async (ctx) => {
const $ = formal(response.data);
const list = $('.data').splice(0, 10);
const list = $('.data').slice(0, 10);
ctx.state.data = {
title: '四川旅游学院',

View File

@ -16,7 +16,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(data);
const list = $('.list_dt a').splice(0, 10);
const list = $('.list_dt a').slice(0, 10);
ctx.state.data = {
title: '四川旅游学院信息与工程系',

View File

@ -21,7 +21,7 @@ module.exports = async (ctx) => {
const $ = formal(response.data);
const list = $('#list2').splice(0, 10);
const list = $('#list2').slice(0, 10);
ctx.state.data = {
title: '四川旅游学院信息与工程学院',

View File

@ -22,7 +22,7 @@ module.exports = async (ctx) => {
const $ = formal(response.data);
const list = $('#list1 ul li').splice(0, 10);
const list = $('#list1 ul li').slice(0, 10);
ctx.state.data = {
title: '四川旅游学院',

View File

@ -14,7 +14,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data);
const list = $('#list_right_list a')
.splice(0, 10)
.slice(0, 10)
.map((i, e) => $(e).attr('href'))
.get();

View File

@ -14,7 +14,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data);
const list = $('#page_right_main li a')
.splice(0, 10)
.slice(0, 10)
.map((i, e) => $(e).attr('href'))
.get();

View File

@ -11,7 +11,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data);
const list = $('#div_more_news a')
.splice(0, 10)
.slice(0, 10)
.map((i, e) => $(e).attr('href'))
.get();

View File

@ -14,7 +14,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data);
const list = $('#page_list li a')
.splice(0, 10)
.slice(0, 10)
.map((i, e) => $(e).attr('href'))
.get();

View File

@ -15,7 +15,7 @@ module.exports = async (ctx) => {
const dateDict = {};
const list = $('#div_more_news .leftNews')
.splice(0, 10)
.slice(0, 10)
.map((i, e) => {
const divs = $(e).children();
let c_link = $('a', divs[1]).attr('href');

View File

@ -19,7 +19,7 @@ module.exports = async (ctx) => {
const id = map.get(type).id;
const items = $(`#${id} tr tr`)
.splice(0, 10)
.slice(0, 10)
.map((_, elem) => {
const a = $('td:first-child > a', elem);
return {

View File

@ -13,7 +13,7 @@ module.exports = async (ctx) => {
});
const $ = cheerio.load(response.data);
const text = $('tr', 'tbody').splice(0, 10);
const text = $('tr', 'tbody').slice(0, 10);
ctx.state.data = {
title: '上海海事大学 学术讲座',

View File

@ -15,7 +15,7 @@ module.exports = async (ctx) => {
});
const $ = cheerio.load(response.data);
const text = $('.gvRow', '.tdMCViewList').splice(0, 10);
const text = $('.gvRow', '.tdMCViewList').slice(0, 10);
ctx.state.data = {
title: `上海海事大学 ${info}`,

View File

@ -13,7 +13,7 @@ module.exports = async (ctx) => {
});
const $ = cheerio.load(response.data);
const text = $('tr', 'tbody').splice(0, 10);
const text = $('tr', 'tbody').slice(0, 10);
ctx.state.data = {
title: '上海海事大学 通知公告',

View File

@ -25,7 +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)
.slice(0, 10)
.map(function(index, ele) {
return {
title: $(ele).attr('title'),

View File

@ -19,7 +19,7 @@ module.exports = async (ctx) => {
const data = response.data;
const $ = cheerio.load(data);
const list = $('.comm li').splice(0, 10);
const list = $('.comm li').slice(0, 10);
const result = await util.ProcessFeed(list, ctx.cache, url);

View File

@ -11,7 +11,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data);
const list = $('.list_style_1 li a')
.splice(0, 10)
.slice(0, 10)
.map((i, e) => $(e).attr('href'))
.get();

View File

@ -11,7 +11,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data);
const list = $('.list_box_5 li')
.splice(0, 10)
.slice(0, 10)
.map((i, e) => ({
date: $(e)
.children('span')

View File

@ -11,7 +11,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data);
const list = $('.list_box_5 li')
.splice(0, 10)
.slice(0, 10)
.map((i, e) => ({
date: $(e)
.children('span')

View File

@ -11,7 +11,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data);
const list = $('.list_box_5 li')
.splice(0, 10)
.slice(0, 10)
.map((i, e) => ({
date: $(e)
.children('span')

View File

@ -11,7 +11,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data);
const list = $('.list_box_5 li')
.splice(0, 10)
.slice(0, 10)
.map((i, e) => ({
date: $(e)
.children('span')

View File

@ -11,7 +11,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data);
const list = $('.list_box_5 li')
.splice(0, 10)
.slice(0, 10)
.map((i, e) => ({
date: $(e)
.children('span')

View File

@ -39,7 +39,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data);
const list = $('.list_box_5_2 li')
.splice(0, 10)
.slice(0, 10)
.map((i, e) => ({
date: $(e)
.children('span')

View File

@ -9,7 +9,7 @@ module.exports = async (ctx) => {
const $ = load(data);
const urls = $('.view-content li > a')
.splice(0, 10)
.slice(0, 10)
.map((_, ele) => $(ele).attr('href'))
.toArray()
.map((path) => path.match(/\/content\/(\d+)/)[1]) // extract article-id

View File

@ -24,7 +24,7 @@ module.exports = async (ctx) => {
const a = $('ul.data-list')
.find('a')
.splice(0, 10);
.slice(0, 10);
for (let i = 0; i < a.length; ++i) {
const tmp = $(a[i]).attr('href');

View File

@ -27,7 +27,7 @@ module.exports = async (ctx) => {
title: '电子科技大学教务处通知公告',
link: baseUrl,
item: $('div[class="textAreo clearfix"] a')
.splice(0, 10)
.slice(0, 10)
.map((_, elem) => ({
link: detailUrl + elem.attribs.newsid,
title: elem.attribs.title,

View File

@ -22,7 +22,7 @@ module.exports = async (ctx) => {
title: '电子科技大学新闻中心',
link: baseUrl,
item: $('div[id="Degas_news_list"] ul li h3 a')
.splice(0, 10)
.slice(0, 10)
.map((_, elem) => ({
link: baseUrl + elem.attribs.href,
title: $(elem).text(),

View File

@ -4,7 +4,7 @@ const cheerio = require('cheerio');
const host = 'http://www.wzbc.edu.cn';
const parserAbb = ($) => {
const items = $('.newslist li').splice(0, 10);
const items = $('.newslist li').slice(0, 10);
return {
title: $('title').text(),
item:
@ -24,7 +24,7 @@ const parserAbb = ($) => {
};
const parserFull = ($) => {
const items = $('.picnewlist li').splice(0, 10);
const items = $('.picnewlist li').slice(0, 10);
return {
title: $('title').text(),
item: