fix: FZU add detailed discription

This commit is contained in:
Lao-Liu233
2020-11-12 15:58:23 +08:00
parent f23b3cf7c3
commit f2d49b49a9
2 changed files with 98 additions and 12 deletions

View File

@@ -1,4 +1,5 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const response = await got({
method: 'get',
@@ -9,15 +10,57 @@ module.exports = async (ctx) => {
});
const data = response.data.data;
const urls = [];
for (const key of data) {
urls.push(key.url);
};
const mains = [];
for (const key of urls) {
const response = await got(key);
const data1 = response.data;
const $ = cheerio.load(data1);
$('.padTB15').remove();
$('.c-txt').remove();
const main = $('.xl_main');
mains.push(main.html());
}
/*
const mains = [];
await Promise.all(urls.map(async (item) => {
console.log(item);
const response = await got({
method: 'get',
url: item,
headers: {
Referer: `http://jwch.fzu.edu.cn/jxtz/`,
},
});
const data1 = response.data;
const $ = cheerio.load(data1);
$('.padTB15').remove();
$('.c-txt').remove();
const main = $('.xl_main');
console.log(item);
mains.push(main.html());
return mains;
}));
*/
let i = -1;
ctx.state.data = {
title: `福州大学教务处教学通知`,
link: `http://jwch.fzu.edu.cn/jxtz/`,
description: `福州大学教务处教学通知`,
item: data.map((item) => ({
title: item.title,
description: `${item.title}`,
pubDate: `${item.adddate}`,
link: `${item.url}`,
})),
item: data.map((item) => {
i++;
return {
title: item.title,
description: `${mains[i]}`,
pubDate: `${item.adddate}`,
link: `${item.url}`,
};
}),
};
};

View File

@@ -1,4 +1,5 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const response = await got({
method: 'get',
@@ -9,15 +10,57 @@ module.exports = async (ctx) => {
});
const data = response.data.data;
const urls = [];
for (const key of data) {
urls.push(key.url);
};
const mains = [];
for (const key of urls) {
const response = await got(key);
const data1 = response.data;
const $ = cheerio.load(data1);
$('.padTB15').remove();
$('.c-txt').remove();
const main = $('.xl_main');
mains.push(main.html());
}
/*
const mains = [];
await Promise.all(urls.map(async (item) => {
console.log(item);
const response = await got({
method: 'get',
url: item,
headers: {
Referer: `http://jwch.fzu.edu.cn/jxtz/`,
},
});
const data1 = response.data;
const $ = cheerio.load(data1);
$('.padTB15').remove();
$('.c-txt').remove();
const main = $('.xl_main');
console.log(item);
mains.push(main.html());
return mains;
}));
*/
let i = -1;
ctx.state.data = {
title: `福州大学教务处专家讲座`,
link: `http://jwch.fzu.edu.cn/zjjz/`,
description: `福州大学教务处加锡讲坛/信息素养讲座通知`,
item: data.map((item) => ({
title: item.title,
description: `${item.title}`,
pubDate: `${item.adddate}`,
link: `${item.url}`,
})),
item: data.map((item) => {
i++;
return {
title: item.title,
description: `${mains[i]}`,
pubDate: `${item.adddate}`,
link: `${item.url}`,
};
}),
};
};