chore(deps-dev): bump prettier from 1.19.1 to 2.0.2

This commit is contained in:
DIYgod 2020-04-02 21:21:46 +08:00
parent 27e4a7c151
commit 0e7b14e718
No known key found for this signature in database
GPG Key ID: EC0B76A252D3EF67
471 changed files with 1237 additions and 4457 deletions

View File

@ -34,7 +34,7 @@ module.exports = {
},
},
markdown: {
slugify: function(s) {
slugify: function (s) {
return _slugify(
pinyin(s, {
style: pinyin.STYLE_NORMAL,

View File

@ -143,14 +143,8 @@ Create a new js script in [/lib/routes/](https://github.com/DIYgod/RSSHub/tree/m
item = $(item);
itemPicUrl = `${item.find('a.cover').attr('style')}`.replace('background-image:url(', '').replace(')', '');
return {
title: item
.find('.title a')
.first()
.text(),
description: `作者:${item
.find('.usr-pic a')
.last()
.text()}<br>描述:${item.find('.content p').text()}<br><img src="${itemPicUrl}">`,
title: item.find('.title a').first().text(),
description: `作者:${item.find('.usr-pic a').last().text()}<br>描述:${item.find('.content p').text()}<br><img src="${itemPicUrl}">`,
link: item.find('.title a').attr('href'),
};
})
@ -205,22 +199,11 @@ Create a new js script in [/lib/routes/](https://github.com/DIYgod/RSSHub/tree/m
item: list
.map((i, item) => ({
// the article title
title: $(item)
.find('.item-title a')
.text()
.trim(),
title: $(item).find('.item-title a').text().trim(),
// the article link
link: url.resolve(
link,
$(item)
.find('.item-title a')
.attr('href')
),
link: url.resolve(link, $(item).find('.item-title a').attr('href')),
// the article author
author: $(item)
.find('.item-author')
.text()
.trim(),
author: $(item).find('.item-author').text().trim(),
}))
.get(), // use cheerio get() method to transform a cheerio node object array into a node array
};
@ -300,7 +283,7 @@ const description = await ctx.cache.tryGet(link, async () => {
const result = await got.get(link);
const $ = cheerio.load(result.data);
$('img').each(function(i, e) {
$('img').each(function (i, e) {
$(e).attr('src', $(e).attr('data-src'));
});

View File

@ -142,14 +142,8 @@ sidebar: auto
item = $(item);
itemPicUrl = `${item.find('a.cover').attr('style')}`.replace('background-image:url(', '').replace(')', '');
return {
title: item
.find('.title a')
.first()
.text(),
description: `作者:${item
.find('.usr-pic a')
.last()
.text()}<br>描述:${item.find('.content p').text()}<br><img src="${itemPicUrl}">`,
title: item.find('.title a').first().text(),
description: `作者:${item.find('.usr-pic a').last().text()}<br>描述:${item.find('.content p').text()}<br><img src="${itemPicUrl}">`,
link: item.find('.title a').attr('href'),
};
})
@ -205,22 +199,11 @@ sidebar: auto
item: list
.map((i, item) => ({
// 文章标题
title: $(item)
.find('.item-title a')
.text()
.trim(),
title: $(item).find('.item-title a').text().trim(),
// 文章链接
link: url.resolve(
link,
$(item)
.find('.item-title a')
.attr('href')
),
link: url.resolve(link, $(item).find('.item-title a').attr('href')),
// 文章作者
author: $(item)
.find('.item-author')
.text()
.trim(),
author: $(item).find('.item-author').text().trim(),
}))
.get(), // cheerio get() 方法将 cheerio node 对象数组转换为 node 对象数组
};
@ -299,7 +282,7 @@ const description = await ctx.cache.tryGet(link, async () => {
const result = await got.get(link);
const $ = cheerio.load(result.data);
$('img').each(function(i, e) {
$('img').each(function (i, e) {
$(e).attr('src', $(e).attr('data-src'));
});

View File

@ -5,7 +5,7 @@ const md5 = require('@/utils/md5');
const config = require('@/config').value;
const logger = require('@/utils/logger');
module.exports = function(app, options = {}) {
module.exports = function (app, options = {}) {
let available = false;
const { prefix = 'koa-redis-cache:', expire = config.cache.routeExpire, passParam = '', maxLength = Infinity, ignoreQuery = true } = options;
@ -43,7 +43,7 @@ module.exports = function(app, options = {}) {
return value;
}
},
set: function(key, value, maxAge = config.cache.contentExpire) {
set: function (key, value, maxAge = config.cache.contentExpire) {
if (!available) {
return;
}
@ -127,7 +127,7 @@ module.exports = function(app, options = {}) {
};
}
app.context.cache.tryGet = async function(key, getValueFunc, maxAge = config.cache.contentExpire) {
app.context.cache.tryGet = async function (key, getValueFunc, maxAge = config.cache.contentExpire) {
let v = await this.get(key);
if (!v) {
v = await getValueFunc();

View File

@ -13,36 +13,11 @@ module.exports = async (ctx) => {
description: '二次元资讯',
item: list
.map((index, item) => ({
title: $(item)
.find('h3 > a')
.text()
.trim(),
description: `<img src="${$(item)
.find('img')
.attr('src')}" /> <br>
${$(item)
.find('div.p-row')
.text()}`,
link: $(item)
.find('h3 > a')
.attr('href'),
pubDate: new Date(
$(item)
.find('span.fr.time')
.text()
.trim()
.substr(0, 4),
$(item)
.find('span.fr.time')
.text()
.trim()
.substr(5, 2),
$(item)
.find('span.fr.time')
.text()
.trim()
.substr(8, 4)
).toUTCString(),
title: $(item).find('h3 > a').text().trim(),
description: `<img src="${$(item).find('img').attr('src')}" /> <br>
${$(item).find('div.p-row').text()}`,
link: $(item).find('h3 > a').attr('href'),
pubDate: new Date($(item).find('span.fr.time').text().trim().substr(0, 4), $(item).find('span.fr.time').text().trim().substr(5, 2), $(item).find('span.fr.time').text().trim().substr(8, 4)).toUTCString(),
}))
.get(),
};

View File

@ -51,9 +51,7 @@ module.exports = async (ctx) => {
);
ctx.state.data = {
title: `万联网 ${$('.t-h2')
.text()
.replace(' |资讯频道', '')}`,
title: `万联网 ${$('.t-h2').text().replace(' |资讯频道', '')}`,
link: pageUrl,
description: $('meta[name="Description"]').attr('content'),
item: items,

View File

@ -18,18 +18,11 @@ module.exports = async (ctx) => {
const name = $('div.nav_center > a:nth-child(4)').text();
const list = $('#newList > ul > li')
.map(function() {
.map(function () {
const info = {
title: $(this)
.find('a')
.text(),
link: $(this)
.find('a')
.attr('href'),
date: $(this)
.find('span')
.text()
.slice(1, -1),
title: $(this).find('a').text(),
link: $(this).find('a').attr('href'),
date: $(this).find('span').text().slice(1, -1),
};
return info;
})

View File

@ -14,9 +14,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(res.data);
const unnecessary = ['#navigation', '.Headnote', '.Logotype', '.Footer', '.SplashImage-wrapper', '.Cta', '.CartSidebar', '.bottomNavigation'];
batchRemove($, unnecessary);
const list = $('a')
.slice(0, 10)
.get();
const list = $('a').slice(0, 10).get();
const out = await Promise.all(
list.map(async (item) => {
const $ = cheerio.load(item);

View File

@ -13,7 +13,7 @@ async function getAvailableHosts(ctx) {
const response = await got.get(fby_url);
const $ = cheerio.load(response.data);
const hosts = $('ul a')
.map(function() {
.map(function () {
return $(this).attr('href');
})
.get()
@ -34,9 +34,7 @@ module.exports = async (ctx) => {
const list = $('.tr3.t_one').toArray();
$('#breadCrumb span.fr').remove();
const forum_name = $('#breadCrumb')
.text()
.replace(/»/g, '-');
const forum_name = $('#breadCrumb').text().replace(/»/g, '-');
const parseContent = async (htmlString) => {
const $ = cheerio.load(htmlString);
@ -49,7 +47,7 @@ module.exports = async (ctx) => {
pubDate: time ? new Date(time) : new Date(),
};
const test_external_torrent = content.find('a').filter(function() {
const test_external_torrent = content.find('a').filter(function () {
return $(this)
.attr('href')
.match(/\/list\.php\?name=\w{32}/);
@ -72,11 +70,7 @@ module.exports = async (ctx) => {
list.slice(0, 30).map(async (item) => {
const $ = cheerio.load(item);
if (
!$('td > a')
.first()
.attr('title')
) {
if (!$('td > a').first().attr('title')) {
return Promise.resolve('');
}

View File

@ -43,7 +43,7 @@ module.exports = async (ctx) => {
const title = $('h1').text();
const dateStr = $('div.newsDate').text();
$('div.txtContent img').each(function(index, element) {
$('div.txtContent img').each(function (index, element) {
const $el = $(element);
const img_original_data = $el.attr('data-original');
const img_src = $el.attr('src');

View File

@ -18,9 +18,7 @@ module.exports = async (ctx) => {
if (type === 'resource') {
list = $('.ZQ_Left .Llis_4 .lis:first-of-type li').get();
} else {
list = $('.ZQ_Left .lis')
.slice(0, 10)
.get();
list = $('.ZQ_Left .lis').slice(0, 10).get();
}
const items = list.map((i) => {
@ -37,9 +35,7 @@ module.exports = async (ctx) => {
});
ctx.state.data = {
title: $('title')
.text()
.split('_')[0],
title: $('title').text().split('_')[0],
link: url,
item: items,
};

View File

@ -13,32 +13,20 @@ module.exports = async (ctx) => {
const out = await Promise.all(
list.map(async (i) => {
const item = $(i);
const itemUrl = $(item)
.find('.text')
.find('a')
.attr('href');
const itemUrl = $(item).find('.text').find('a').attr('href');
const cache = await ctx.cache.get(itemUrl);
if (cache) {
return Promise.resolve(JSON.parse(cache));
}
const title = $(item)
.find('.text')
.find('.bt')
.text();
const title = $(item).find('.text').find('.bt').text();
const category = $(item)
.find('.text')
.find('.bq')
.find('a')
.text();
const category = $(item).find('.text').find('.bq').find('a').text();
const itemReponse = await got.get(itemUrl);
const itemElement = cheerio.load(itemReponse.data);
const description = itemElement('.news_warp_center').html();
const pageInfo = $(item)
.find('.time')
.text();
const pageInfo = $(item).find('.time').text();
const regex = /\d{4}-\d{2}-\d{2} \d{2}:\d{2}/;
const regRes = regex.exec(pageInfo);
const time = regRes === null ? new Date() : new Date(regRes[0]);
@ -59,11 +47,7 @@ module.exports = async (ctx) => {
);
ctx.state.data = {
title:
'3DM - ' +
$('title')
.text()
.split('_')[0],
title: '3DM - ' + $('title').text().split('_')[0],
link: url,
item: out,
};

View File

@ -24,10 +24,7 @@ module.exports = async (ctx) => {
const link = title.attr('href');
return await ctx.cache.tryGet('3ycy' + link, async () => {
const date = item
.find('div.postSubtitle')
.text()
.trim();
const date = item.find('div.postSubtitle').text().trim();
const match = /(\d+\/\d+\/\d{4}\s+\d+:\d+:\d+\s*(?:AM|PM))/i.exec(date);
const pubDate = match && new Date(match[1] + ' GMT+8').toUTCString();

View File

@ -27,9 +27,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data);
const single = {
title: $('article header h1')
.text()
.trim(),
title: $('article header h1').text().trim(),
link: itemUrl,
author: '99% Invisible',
description: $('article .page-content').html(),

View File

@ -10,10 +10,7 @@ const ProcessFeed = (data) => {
}
// remove useless DOMs
content
.find('hr')
.nextAll()
.remove();
content.find('hr').nextAll().remove();
content.find('hr, ins.adsbygoogle, script').each((i, e) => {
$(e).remove();

View File

@ -33,14 +33,7 @@ module.exports = async (ctx) => {
let bio;
const authorInfo = '.article__body__author-details > p:nth-child(2)';
if (capture(authorInfo).html() !== null) {
bio =
`<br><br><br><br><hr><br><b>` +
author.trim() +
'</b> ' +
capture(authorInfo)
.html()
.trim() +
`<p><hr>`;
bio = `<br><br><br><br><hr><br><b>` + author.trim() + '</b> ' + capture(authorInfo).html().trim() + `<p><hr>`;
capture('.article__inline-sidebar').remove();
} else {
bio = '';

View File

@ -17,9 +17,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data);
const list = $('.search_list > ul > li > a:nth-child(2)')
.slice(0, 10)
.get();
const list = $('.search_list > ul > li > a:nth-child(2)').slice(0, 10).get();
const columnName = $('.search_list > ul > li:nth-child(1) > a:nth-child(1)').text();

View File

@ -17,9 +17,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data);
const list = $('.tops_list > .tips > a')
.slice(0, 10)
.get();
const list = $('.tops_list > .tips > a').slice(0, 10).get();
const columnName = $('.tops_text > h3')[0].firstChild.nodeValue;

View File

@ -4,10 +4,7 @@ const got = require('@/utils/got');
const date = require('@/utils/date');
const ProcessFeed = async (link) => {
const id = link
.split('/')
.pop()
.split('.')[0];
const id = link.split('/').pop().split('.')[0];
let response;
response = await got.get(`http://www.aisixiang.com/data/view_json.php?id=${id}`, {
@ -26,13 +23,7 @@ const ProcessFeed = async (link) => {
const title = $('.show_text > h3').text();
const pubDate = date(
$('.show_text > .info')
.text()
.split('')
.pop(),
8
);
const pubDate = date($('.show_text > .info').text().split('').pop(), 8);
return {
title: title.split('')[1] || title,

View File

@ -83,15 +83,10 @@ module.exports = async (ctx) => {
$('tr')
.slice(1)
.each((i, e) => {
const id = $(e)
.find('th')
.text();
const id = $(e).find('th').text();
const titleLabel = $(e).find('td a');
const title = `${id}. ${titleLabel.text()}`;
const episode = titleLabel
.attr('href')
.trim()
.split('/')[2];
const episode = titleLabel.attr('href').trim().split('/')[2];
const link = `http://algocasts.io/episodes/${episode}`;
infos.push({ id, title, episode, link });

View File

@ -9,16 +9,8 @@ module.exports = async (ctx) => {
const list = $("ul[class='posts'] > li")
.map((i, e) => {
const element = $(e);
const title = element
.find('a')
.text()
.trim();
const link =
'http://mysql.taobao.org' +
element
.find('a')
.attr('href')
.trim();
const title = element.find('a').text().trim();
const link = 'http://mysql.taobao.org' + element.find('a').attr('href').trim();
return {
title: title,
description: '',

View File

@ -25,16 +25,8 @@ module.exports = async (ctx) => {
const list = $('ul > li.y-clear')
.map((i, e) => {
const element = $(e);
const title = element
.find('a')
.text()
.trim();
const link =
'https://help.aliyun.com' +
element
.find('a')
.attr('href')
.trim();
const title = element.find('a').text().trim();
const link = 'https://help.aliyun.com' + element.find('a').attr('href').trim();
const date = element.find('.y-right').text();
const pubDate = dayjs(`${date} +0800`, 'YYYY-MM-DDHH:mm:ss ZZ');
return {
@ -65,9 +57,7 @@ module.exports = async (ctx) => {
);
ctx.state.data = {
title: $('title')
.text()
.trim(),
title: $('title').text().trim(),
link: url,
item: result,
};

View File

@ -19,23 +19,15 @@ module.exports = async (ctx) => {
const items = $('.sub')
.get()
.map((e) => {
let itemUrl = $(e)
.find('h1.title > a')
.attr('href');
let itemUrl = $(e).find('h1.title > a').attr('href');
itemUrl = url.resolve(host, itemUrl);
const single = {
title: $(e)
.find('h1.title > a')
.text(),
description: $(e)
.find('div.poem_body')
.html(),
title: $(e).find('h1.title > a').text(),
description: $(e).find('div.poem_body').html(),
link: itemUrl,
author: $(e)
.find('div.bio >a ')
.attr('data-name'),
author: $(e).find('div.bio >a ').attr('data-name'),
guid: itemUrl,
};

View File

@ -26,27 +26,10 @@ module.exports = async (ctx) => {
item: $('.bm_c')
.find('tbody')
.map((index, item) => ({
title:
`` +
$(item)
.find('td.by a')
.eq(0)
.text() +
`` +
$(item)
.find('a.xst')
.text(),
title: `` + $(item).find('td.by a').eq(0).text() + `` + $(item).find('a.xst').text(),
description: '',
author: $(item)
.find('cite')
.text()
.trim(),
link:
host +
$(item)
.find('a')
.eq(0)
.attr('href'),
author: $(item).find('cite').text().trim(),
link: host + $(item).find('a').eq(0).attr('href'),
}))
.get(),
};

View File

@ -4,9 +4,7 @@ const cheerio = require('cheerio');
module.exports = async (ctx) => {
const { time, name } = ctx.params;
const $ = await got.get(`https://anime1.me/category/${encodeURIComponent(time)}/${encodeURIComponent(name)}`).then((r) => cheerio.load(r.data));
const title = $('.page-title')
.text()
.trim();
const title = $('.page-title').text().trim();
ctx.state.data = {
title,
link: `https://anime1.me/category/${time}/${name}`,

View File

@ -4,9 +4,7 @@ const cheerio = require('cheerio');
module.exports = async (ctx) => {
const { keyword } = ctx.params;
const $ = await got.get(`https://anime1.me/?s=${encodeURIComponent(keyword)}`).then((r) => cheerio.load(r.data));
const title = $('.page-title')
.text()
.trim();
const title = $('.page-title').text().trim();
ctx.state.data = {
title,
link: `https://anime1.me/?s=${keyword}`,

View File

@ -50,7 +50,7 @@ module.exports = async (ctx) => {
const response = await got.get(news_detail_api);
const details = response.data.news_content.slice(1);
const descriptions = details.map(function(detail) {
const descriptions = details.map(function (detail) {
let description;
if (detail.news_order_type === 'M') {
const id = detail.content.split('=')[1];

View File

@ -11,9 +11,7 @@ module.exports = async (ctx) => {
});
const $ = cheerio.load(response.data);
const channel_name = $('#area-article-channel .bar')
.text()
.slice(0, -5);
const channel_name = $('#area-article-channel .bar').text().slice(0, -5);
const list = $('#area-article-channel div.inner a')
.slice(0, 10)
.map((i, e) => ({

View File

@ -31,11 +31,7 @@ module.exports = async (ctx) => {
const detail_urls = [];
for (let i = 1; i < count + 1; ++i) {
// i = 1: first tr is table title, ignore
const link =
base_url +
$(list[i])
.find('a')
.attr('href');
const link = base_url + $(list[i]).find('a').attr('href');
detail_urls.push(link);
}
@ -56,19 +52,13 @@ module.exports = async (ctx) => {
for (let j = 0; j < title_info.length; ++j) {
const tmp = he.decode($(title_info[j]).html()); // should convert from escaped to unicode
if (tmp.includes('作品名:')) {
title = $(title_info[j])
.find('td:nth-child(2)')
.text();
title = $(title_info[j]).find('td:nth-child(2)').text();
}
if (tmp.includes('副題:')) {
title_sub = $(title_info[j])
.find('td:nth-child(2)')
.text();
title_sub = $(title_info[j]).find('td:nth-child(2)').text();
}
if (tmp.includes('著者名:')) {
author = $(title_info[j])
.find('td:nth-child(2)')
.text();
author = $(title_info[j]).find('td:nth-child(2)').text();
}
}
if (title_sub !== '') {

View File

@ -14,25 +14,10 @@ module.exports = async (ctx) => {
item: $('.ver li')
.toArray()
.map((ver) => ({
title: $(ver)
.find('.ver-item-n')
.text(),
description: $(ver)
.find('a')
.attr('title'),
link: `https://apkpure.com${decodeURI(
$(ver)
.find('a')
.attr('href')
.split('?from')[0]
)}`,
pubDate: new Date(
$(ver)
.find('.update-on')
.text()
.replace(/年|月/g, '-')
.replace('日', '')
).toUTCString(),
title: $(ver).find('.ver-item-n').text(),
description: $(ver).find('a').attr('title'),
link: `https://apkpure.com${decodeURI($(ver).find('a').attr('href').split('?from')[0])}`,
pubDate: new Date($(ver).find('.update-on').text().replace(/年|月/g, '-').replace('日', '')).toUTCString(),
})),
};
};

View File

@ -15,24 +15,15 @@ module.exports = async (ctx) => {
const $ = cheerio.load(data);
// const list = $('div.FeedCard');
const list = [];
$('div.FeedCard').each(function(index, item) {
if (
$(item)
.find('a[class^=Component-headline]')
.attr('href') !== undefined
) {
$('div.FeedCard').each(function (index, item) {
if ($(item).find('a[class^=Component-headline]').attr('href') !== undefined) {
list.push(item);
}
});
const out = await Promise.all(
list.map(async (article) => {
const link = url.resolve(
'https://apnews.com',
$(article)
.find('a[class^=Component-headline]')
.attr('href')
);
const link = url.resolve('https://apnews.com', $(article).find('a[class^=Component-headline]').attr('href'));
const [title, author, pubDate, description] = await ctx.cache.tryGet(link, async () => {
const result = await got.get(link);

View File

@ -17,10 +17,8 @@ module.exports = async (ctx) => {
const items = [];
if ($('.whats-new').length > 0) {
$('.whats-new').each(function() {
const version = $('.whats-new__latest__version')
.text()
.split(' ')[1];
$('.whats-new').each(function () {
const version = $('.whats-new__latest__version').text().split(' ')[1];
const date = $('.whats-new__content time').attr('aria-label');
const item = {};
item.title = `${titleTags.text().trim()} ${version}`;

View File

@ -10,9 +10,7 @@ module.exports = async (ctx) => {
const response = await got.get(link);
const $ = cheerio.load(response.data);
const list = $('section.as-columns')
.get()
.slice(0, 5);
const list = $('section.as-columns').get().slice(0, 5);
const out = await Promise.all(
list.map(async (item) => {

View File

@ -20,11 +20,7 @@ module.exports = async (ctx) => {
description: `
<img src="${url.resolve(link, item.find('img').attr('src'))}"/>
<br/>
${$(item.find('td')[1])
.children()
.remove()
.end()
.text()}
${$(item.find('td')[1]).children().remove().end().text()}
`,
pubDate: new Date().toUTCString(),
link: url.resolve(link, item.find('td.icon a').attr('href')),

View File

@ -13,16 +13,8 @@ module.exports = async (ctx) => {
const title = item.find('td:first-child a').text();
const cve = item.find('td:nth-child(2)').text();
const pla = item
.find('.vul-type-item')
.text()
.replace(/\s+/g, '');
const date = new Date(
item
.find('td:nth-last-child(2)')
.text()
.replace(/\s+/g, '')
).toUTCString();
const pla = item.find('.vul-type-item').text().replace(/\s+/g, '');
const date = new Date(item.find('td:nth-last-child(2)').text().replace(/\s+/g, '')).toUTCString();
const href = item.find('a').attr('href');
return {

View File

@ -16,28 +16,17 @@ module.exports = async (ctx) => {
newslist
.map(async (index, item) => {
const sth = $(item);
const link = `https://ak.hypergryph.com${sth
.find('a')
.attr('href')
.slice(1)}`;
const link = `https://ak.hypergryph.com${sth.find('a').attr('href').slice(1)}`;
const description = await ctx.cache.tryGet(link, async () => {
const result = await got.get(link);
const $ = cheerio.load(result.data);
return $('.article-inner').html();
});
return {
title: sth
.find('.news-title')
.first()
.text(),
title: sth.find('.news-title').first().text(),
description,
link,
pubDate: new Date(
sth
.find('.news-date-text')
.first()
.text()
),
pubDate: new Date(sth.find('.news-date-text').first().text()),
};
})
.get()

View File

@ -56,17 +56,11 @@ module.exports = async (ctx) => {
const list = $('ul.List li')
.slice(1, 11)
.map(function() {
.map(function () {
const info = {
title: $(this)
.find('a')
.text(),
link: $(this)
.find('a')
.attr('href'),
date: $(this)
.find('span.Date')
.text(),
title: $(this).find('a').text(),
link: $(this).find('a').attr('href'),
date: $(this).find('span.Date').text(),
};
logger.info(info.date);
return info;
@ -87,9 +81,7 @@ module.exports = async (ctx) => {
const response = await got.get(itemUrl);
const $ = cheerio.load(response.data);
const description = $('div.ArticleText')
.html()
.trim();
const description = $('div.ArticleText').html().trim();
const single = {
title: title,

View File

@ -56,17 +56,11 @@ module.exports = async (ctx) => {
const list = $('ul.List li')
.slice(1, 11)
.map(function() {
.map(function () {
const info = {
title: $(this)
.find('a')
.text(),
link: $(this)
.find('a')
.attr('href'),
date: $(this)
.find('span.Date')
.text(),
title: $(this).find('a').text(),
link: $(this).find('a').attr('href'),
date: $(this).find('span.Date').text(),
};
logger.info(info.date);
return info;
@ -87,9 +81,7 @@ module.exports = async (ctx) => {
const response = await got.get(itemUrl);
const $ = cheerio.load(response.data);
const description = $('div.ArticleText')
.html()
.trim();
const description = $('div.ArticleText').html().trim();
const single = {
title: title,

View File

@ -12,7 +12,7 @@ module.exports = async (ctx) => {
let url = 'https://alltheflightdeals.com/deals/locations?origins=[';
locations.split(',').forEach(function(pair) {
locations.split(',').forEach(function (pair) {
const country = pair.split('+')[0];
const city = toTitleCase(pair.split('+')[1]);
url += `{"country":"${country}","city":"${city}"},`;

View File

@ -7,9 +7,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data.html);
const idList = $('li.search-page__result')
.slice(0, 10)
.get();
const idList = $('li.search-page__result').slice(0, 10).get();
const items = await Promise.all(
idList.map(async (item) => {
@ -34,11 +32,7 @@ module.exports = async (ctx) => {
keyFacts += '</tr><tr>';
$('.fpaSpecifications__economy .fpaSpecifications__listItem').each((i, e) => {
keyFacts += `<td>${$(e)
.find('.fpaSpecifications__term')
.text()}: ${$(e)
.find('.fpaSpecifications__description')
.text()}</td>`;
keyFacts += `<td>${$(e).find('.fpaSpecifications__term').text()}: ${$(e).find('.fpaSpecifications__description').text()}</td>`;
if ((i + 1) % 4 === 0) {
keyFacts += '</tr><tr>';
}

View File

@ -28,20 +28,11 @@ module.exports = async (ctx) => {
const title = $('h1.xs2 a').text();
const out = $('tbody[id^="normalthread"]')
.slice(0, 10)
.map(function() {
.map(function () {
const info = {
title: $(this)
.find('td:nth-child(2) > a:nth-child(1)')
.text(),
link: url.resolve(
host,
$(this)
.find('td:nth-child(2) > a:nth-child(1)')
.attr('href')
),
author: $(this)
.find('td.by.by_author cite a')
.text(),
title: $(this).find('td:nth-child(2) > a:nth-child(1)').text(),
link: url.resolve(host, $(this).find('td:nth-child(2) > a:nth-child(1)').attr('href')),
author: $(this).find('td.by.by_author cite a').text(),
};
return info;
})

View File

@ -31,9 +31,7 @@ module.exports = {
const title = $('.HOME-mainbox1b > h1 > a');
const link = base + title.attr('href');
const author = $('.HOME-mainbox1b > .ST1 > a').text();
const time = $('.HOME-mainbox1b > .ST1')
.text()
.split('│')[1];
const time = $('.HOME-mainbox1b > .ST1').text().split('│')[1];
const cache = await ctx.cache.get(link);
if (cache) {

View File

@ -16,15 +16,7 @@ module.exports = async (ctx) => {
id: $el.attr('id'),
author: $el.find('.userInfo .l').text(),
content: $el.find('.reply_content .message').html(),
date: $el
.children()
.first()
.find('small')
.children()
.remove()
.end()
.text()
.slice(3),
date: $el.children().first().find('small').children().remove().end().text().slice(3),
};
})
.get()

View File

@ -6,9 +6,7 @@ module.exports = async (subjectID, minLength) => {
const link = `https://bgm.tv/subject/${subjectID}/comments`;
const html = (await got.get(link)).data;
const $ = cheerio.load(html);
const title = $('.nameSingle')
.find('a')
.text();
const title = $('.nameSingle').find('a').text();
const comments = $('.item')
.map((i, el) => {
const $el = $(el);
@ -18,10 +16,7 @@ module.exports = async (subjectID, minLength) => {
rate = $rateEl.attr('class').match(/sstars(\d)/)[1];
}
const dateString = $el
.find('small.grey')
.text()
.slice(2);
const dateString = $el.find('small.grey').text().slice(2);
let date;
if (dateString.includes('ago')) {
// 处理表示相对日期的字符串

View File

@ -11,17 +11,11 @@ module.exports = async (ctx) => {
const list = $('ul.clearFix li')
.slice(0, 10)
.map(function() {
.map(function () {
const info = {
title: $(this)
.find('h3 a')
.text(),
link: $(this)
.find('h3 a')
.attr('href'),
date: $(this)
.find('span.tag3')
.text(),
title: $(this).find('h3 a').text(),
link: $(this).find('h3 a').attr('href'),
date: $(this).find('span.tag3').text(),
};
return info;
})

View File

@ -14,17 +14,13 @@ const ProcessImage = ($, e, c) => {
// add image caption
const figcaption = $(e).find('.media-caption__text');
if (figcaption.length > 0) {
message += `${$(figcaption[0])
.text()
.trim()}`;
message += `${$(figcaption[0]).text().trim()}`;
}
// add image copyright
const copyright = $(e).find('.story-image-copyright');
if (copyright.length > 0) {
message += ` ©${$(copyright[0])
.text()
.trim()}`;
message += ` ©${$(copyright[0]).text().trim()}`;
}
message += '</figcaption></figure>';

View File

@ -16,7 +16,7 @@ module.exports = async (ctx) => {
link: 'https://www.bilibili.com/blackboard/topic_list.html#/',
description: 'bilibili 话题列表',
item: data
.filter(function(item, index, array) {
.filter(function (item, index, array) {
// 由于某些话题在不同平台上是同时分开发布的,会产生重复,在这里去除
return !index || item.name !== array[index - 1].name;
})

View File

@ -33,12 +33,7 @@ module.exports = async (ctx) => {
const item = {
title: $(e).attr('title'),
pubDate: new Date($('meta[name=pubDate]').attr('content')).toUTCString(),
description:
image +
content
.find('table')
.last()
.html(),
description: image + content.find('table').last().html(),
link,
guid: link,
};

View File

@ -69,15 +69,9 @@ async function fetchPage(ctx, link) {
const item = {
title: $page('.list_detail > h1').text(),
description: pages.reduce((desc, $p) => desc + $p('#content').html(), ''),
pubDate: date(
$page('.list_detail .list_copy b')
.last()
.text()
),
pubDate: date($page('.list_detail .list_copy b').last().text()),
link,
author: $page('.list_detail .list_copy b')
.first()
.text(),
author: $page('.list_detail .list_copy b').first().text(),
};
ctx.cache.set(link, JSON.stringify(item));
return item;

View File

@ -15,15 +15,9 @@ module.exports = async (ctx) => {
return {
title: $link.text(),
description: elem
.find('dd')
.eq(0)
.text(),
description: elem.find('dd').eq(0).text(),
link: $link.attr('href'),
author: elem
.find('.small a')
.eq(0)
.text(),
author: elem.find('.small a').eq(0).text(),
};
})
.get();

View File

@ -20,11 +20,7 @@ module.exports = async (ctx) => {
list
.map((index, item) => {
item = $(item);
const title = item
.find('.gk-desc p')
.eq(0)
.text()
.slice(3);
const title = item.find('.gk-desc p').eq(0).text().slice(3);
return {
title,
description: item.html(),

View File

@ -10,19 +10,14 @@ module.exports = async (ctx) => {
url: url,
});
const $ = cheerio.load(res.data);
const title = $('div[class="StyledBox-sc-13pk1d4-0 heWGCm"]')
.find('h1')
.text();
const title = $('div[class="StyledBox-sc-13pk1d4-0 heWGCm"]').find('h1').text();
const list = $('div[class="StyledBox-sc-13pk1d4-0 czKiZd"]')
.find('div[class="StyledBox-sc-13pk1d4-0 czKiZd"]')
.find('div[class="StyledBox-sc-13pk1d4-0 czKiZd"]')
.map((i, e) => {
const element = $(e);
const title = element
.find('a')
.find('h3')
.text();
const title = element.find('a').find('h3').text();
const link = url + element.find('a').attr('href');
return {
title: title,
@ -44,9 +39,7 @@ module.exports = async (ctx) => {
const itemReponse = await got.get(link);
const itemElement = cheerio.load(itemReponse.data);
// Remove duplicate title
itemElement('.StyledBox-sc-13pk1d4-0 .bpdfin')
.find('h1[class="StyledHeading-sc-1rdh4aw-0 kIYNxP"]')
.remove();
itemElement('.StyledBox-sc-13pk1d4-0 .bpdfin').find('h1[class="StyledHeading-sc-1rdh4aw-0 kIYNxP"]').remove();
item.description = itemElement('.StyledBox-sc-13pk1d4-0 .bpdfin').html();
ctx.cache.set(link, JSON.stringify(item));

View File

@ -9,15 +9,9 @@ module.exports = async (ctx) => {
const list = $('div.post')
.map((i, e) => ({
title: $(e)
.find('h3 > a')
.text(),
description: $(e)
.find('.post-body')
.html(),
link: $(e)
.find('h3 > a')
.attr('href'),
title: $(e).find('h3 > a').text(),
description: $(e).find('.post-body').html(),
link: $(e).find('h3 > a').attr('href'),
author: '王五四',
}))
.get();

View File

@ -40,37 +40,21 @@ module.exports = async (ctx) => {
const out = $('div.publish table tbody tr')
.slice(2)
.map(function() {
const zh_name = $(this)
.find('td:nth-child(1)')
.text();
.map(function () {
const zh_name = $(this).find('td:nth-child(1)').text();
const en_name = en_names[zh_name] || '';
const name = `${zh_name} ${en_name} `;
const date = `${$(this)
.find('td:nth-child(7)')
.text()} ${$(this)
.find('td:nth-child(8)')
.text()}`;
const date = `${$(this).find('td:nth-child(7)').text()} ${$(this).find('td:nth-child(8)').text()}`;
const xhmr = `现汇买入价:${$(this)
.find('td:nth-child(2)')
.text()}`;
const xhmr = `现汇买入价:${$(this).find('td:nth-child(2)').text()}`;
const xcmr = `现钞买入价:${$(this)
.find('td:nth-child(3)')
.text()}`;
const xcmr = `现钞买入价:${$(this).find('td:nth-child(3)').text()}`;
const xhmc = `现汇卖出价:${$(this)
.find('td:nth-child(4)')
.text()}`;
const xhmc = `现汇卖出价:${$(this).find('td:nth-child(4)').text()}`;
const xcmc = `现钞卖出价:${$(this)
.find('td:nth-child(5)')
.text()}`;
const xcmc = `现钞卖出价:${$(this).find('td:nth-child(5)').text()}`;
const zs = `中行折算价:${$(this)
.find('td:nth-child(6)')
.text()}`;
const zs = `中行折算价:${$(this).find('td:nth-child(6)').text()}`;
const content = `${xhmr} ${xcmr} ${xhmc} ${xcmc} ${zs}`;

View File

@ -21,25 +21,10 @@ module.exports = async (ctx) => {
for (let i = 0; i < list.length; i++) {
const item = {
title: $(list[i])
.children('h4')
.children()
.text(),
desc: $(list[i])
.children('p')
.text(),
pubDate: new Date(
$(list[i])
.children('span')
.text()
.replace('年', '-')
.replace('月', '-')
.replace('日', '')
).toUTCString(),
url: $(list[i])
.children('h4')
.children()
.attr('href'),
title: $(list[i]).children('h4').children().text(),
desc: $(list[i]).children('p').text(),
pubDate: new Date($(list[i]).children('span').text().replace('年', '-').replace('月', '-').replace('日', '')).toUTCString(),
url: $(list[i]).children('h4').children().attr('href'),
};
items.push(item);
}

View File

@ -17,9 +17,7 @@ const load = ($, baseUrl) => {
};
const getChapters = async (id, $, caches) => {
const chapters = $('#info')
.eq(1)
.find('a');
const chapters = $('#info').eq(1).find('a');
return await Promise.all(
chapters
@ -54,14 +52,8 @@ module.exports = async (ctx) => {
const content = iconv.decode(new Buffer.from(data), 'big5');
const $ = cheerio.load(content);
const bookTitle = $('title')
.text()
.match(/\S+/)[0];
const bookIntro = $('#info')
.eq(0)
.find('td')
.text()
.trim();
const bookTitle = $('title').text().match(/\S+/)[0];
const bookIntro = $('#info').eq(0).find('td').text().trim();
// const coverImgSrc = $('.cover')
// .parent()
// .find('img')

View File

@ -8,14 +8,7 @@ module.exports = async (ctx) => {
const res = await got({ method: 'get', url: 'http://tv.cctv.com/lm/xwlb/' });
const $ = cheerio.load(res.data);
// 解析最新一期新闻联播的日期
const latestDate = dayjs(
date(
$('.md .mh_title > a')
.text()
.replace(/\s/g, '')
),
{ locale: 'zh-cn' }
);
const latestDate = dayjs(date($('.md .mh_title > a').text().replace(/\s/g, '')), { locale: 'zh-cn' });
const count = [];
for (let i = 0; i < 20; i++) {
count.push(i);

View File

@ -20,7 +20,7 @@ module.exports = async (ctx) => {
const list = pageCapture('item')
.get()
.filter(function(item) {
.filter(function (item) {
const $ = cheerio.load(item);
const section = $('prism\\:section').text();
@ -31,13 +31,7 @@ module.exports = async (ctx) => {
list.map(async (item) => {
const $ = cheerio.load(item);
const section = $('prism\\:section').text();
const address =
alternativeURL +
$('item')
.attr('rdf:about')
.replace('?rss=yes', '')
.split('/')
.pop();
const address = alternativeURL + $('item').attr('rdf:about').replace('?rss=yes', '').split('/').pop();
const title = $('dc\\:title').text();
const author = $('dc\\:creator').text();
const pubDate = new Date($('dc\\:date').text()).toUTCString();
@ -49,7 +43,7 @@ module.exports = async (ctx) => {
const itemCapture = cheerio.load(itemPage.data);
// section + keywords content
const keywords = itemCapture('div.keywords-section > div.keyword')
.map(function(i, el) {
.map(function (i, el) {
return $(el).text();
})
.get()
@ -63,9 +57,7 @@ module.exports = async (ctx) => {
`;
// graphical content
const brief = $('description').text();
const graphical = itemCapture('div.abstract.graphical')
.find('img')
.attr('src');
const graphical = itemCapture('div.abstract.graphical').find('img').attr('src');
let graphicalContents = '';
if (graphical !== '') {
graphicalContents = `

View File

@ -60,16 +60,13 @@ module.exports = async (ctx) => {
const issueDate = $('h1.toc-header__issue-date').text();
const issueNum = $('.toc-header__details span')
.contents()
.map(function() {
.map(function () {
return this.type === 'text' ? $(this).text() : '';
})
.get()
.slice(0, 2)
.join(', ');
const issueName =
$('meta[name="name"]')
.attr('content')
.replace('Issue: ', '') || `Cell ...`;
const issueName = $('meta[name="name"]').attr('content').replace('Issue: ', '') || `Cell ...`;
const m = $('meta[name="pbContext"]')
.attr('content')
.match(/issue:issue:pii\\:(S\d{4})(\d{4})(\d{2})(X\d{4})(\w)/);

View File

@ -13,10 +13,7 @@ module.exports = async (ctx) => {
link: url,
item: list.map((update) => {
update = $(update);
const version = update
.find('p')
.first()
.attr('id');
const version = update.find('p').first().attr('id');
const date = update
.find('p > i')
.text()

View File

@ -13,44 +13,18 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data);
const list = $(':nth-child(11) tbody tr')
.map(function() {
.map(function () {
return {
id: $(this)
.find(':nth-child(2)')
.text(),
visaType: $(this)
.find(':nth-child(3)')
.text(),
visaEntry: $(this)
.find(':nth-child(4)')
.text(),
usConsulate: $(this)
.find(':nth-child(5)')
.text(),
major: $(this)
.find(':nth-child(6)')
.text(),
status: $(this)
.find(':nth-child(7)')
.text(),
checkDate: $(this)
.find(':nth-child(8)')
.text(),
completeDate:
$(this)
.find(':nth-child(9)')
.text() === '0000-00-00'
? 'Not Completed'
: $(this)
.find(':nth-child(9)')
.text(),
link: $(this)
.find(':nth-child(11) a')
.attr('href'),
note:
$(this)
.find(':nth-child(11) a')
.attr('title') || '',
id: $(this).find(':nth-child(2)').text(),
visaType: $(this).find(':nth-child(3)').text(),
visaEntry: $(this).find(':nth-child(4)').text(),
usConsulate: $(this).find(':nth-child(5)').text(),
major: $(this).find(':nth-child(6)').text(),
status: $(this).find(':nth-child(7)').text(),
checkDate: $(this).find(':nth-child(8)').text(),
completeDate: $(this).find(':nth-child(9)').text() === '0000-00-00' ? 'Not Completed' : $(this).find(':nth-child(9)').text(),
link: $(this).find(':nth-child(11) a').attr('href'),
note: $(this).find(':nth-child(11) a').attr('title') || '',
};
})
.get();

View File

@ -21,10 +21,7 @@ module.exports = async (ctx) => {
const address = 'https://checkra.in' + $item.find('a').attr('href');
return {
title: $item
.find('h3')
.first()
.text(),
title: $item.find('h3').first().text(),
description: $item.find('.changelog').html(),
link: address,
guid: address,

View File

@ -8,9 +8,7 @@ module.exports = async (ctx) => {
const response = await got(url);
const $ = cheerio.load(response.data);
const categoryName = $('.CT_title')
.first()
.text();
const categoryName = $('.CT_title').first().text();
const items = $('.gy_box')
.map((_, ele) => {
const $item = cheerio.load(ele);

View File

@ -30,7 +30,7 @@ module.exports = async (ctx) => {
title = [];
description = [];
item.find('h1').each(function(index, element) {
item.find('h1').each(function (index, element) {
title.push(
$(element)
.text()
@ -38,7 +38,7 @@ module.exports = async (ctx) => {
);
});
item.find('p').each(function(index, element) {
item.find('p').each(function (index, element) {
description.push(
$(element)
.text()

View File

@ -32,7 +32,7 @@ module.exports = async (ctx) => {
title = [];
description = [];
item.find('h1').each(function(index, element) {
item.find('h1').each(function (index, element) {
title.push(
$(element)
.text()
@ -40,7 +40,7 @@ module.exports = async (ctx) => {
);
});
item.find('p').each(function(index, element) {
item.find('p').each(function (index, element) {
description.push($(element).text());
});

View File

@ -25,12 +25,7 @@ module.exports = async (ctx) => {
// replace placeholer image url
imgNode.each((index, element) => {
if (
$(element).attr('src') &&
$(element)
.attr('src')
.indexOf('none.gif') !== -1
) {
if ($(element).attr('src') && $(element).attr('src').indexOf('none.gif') !== -1) {
$(element).attr('src', $(element).attr('zoomfile'));
}
@ -40,23 +35,13 @@ module.exports = async (ctx) => {
});
// remove image tips
$(description)
.find('div[class*="aimg_tip"]')
.remove();
$(description)
.find('div[class*="tip"]')
.remove();
$(description)
.find('p[class="mbn"]')
.remove();
$(description).find('div[class*="aimg_tip"]').remove();
$(description).find('div[class*="tip"]').remove();
$(description).find('p[class="mbn"]').remove();
// remove rate infomation
$(description)
.find('dl[class="rate"]')
.remove();
$(description)
.find('h3[class*="psth"]')
.remove();
$(description).find('dl[class="rate"]').remove();
$(description).find('h3[class*="psth"]').remove();
const single = {
title: item.title,

View File

@ -24,9 +24,7 @@ function pick_versions(raw_html) {
software.version = version;
}
if (col_index === 0) {
software.software = $(col)
.text()
.trim();
software.software = $(col).text().trim();
}
if (col_index === 2) {
software.time = $(col).text();

View File

@ -8,9 +8,7 @@ module.exports = async (ctx) => {
method: 'get',
url: `https://chrome.google.com/webstore/detail/${id}?hl=en`,
});
const data = cheerio
.load(response.data)('noscript')
.text();
const data = cheerio.load(response.data)('noscript').text();
const $ = cheerio.load(data);
const version = 'v' + $('.h-C-b-p-D-md').text();

View File

@ -14,7 +14,7 @@ module.exports = async (ctx) => {
const chapter_item = [];
$('.book-chapter>.book-chapter-box>ul>li>a').each(function() {
$('.book-chapter>.book-chapter-box>ul>li>a').each(function () {
chapter_item.push({
title: $(this).text(),
link: $(this).attr('href'),

View File

@ -16,9 +16,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data);
$('.article-entry script').remove();
$('.article-entry .adsbygoogle')
.parent()
.remove();
$('.article-entry .adsbygoogle').parent().remove();
return $('.article-entry').html();
};

View File

@ -14,9 +14,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data);
$('.article-entry script').remove();
$('.article-entry .adsbygoogle')
.parent()
.remove();
$('.article-entry .adsbygoogle').parent().remove();
return $('.article-entry').html();
};

View File

@ -14,22 +14,13 @@ module.exports = async (ctx) => {
const items = list
.filter((_, item) => {
item = $(item);
const dateRaw = item
.find('td:first-child')
.text()
.trim();
const dateRaw = item.find('td:first-child').text().trim();
return dateRaw !== 'Date';
})
.map((_, item) => {
item = $(item);
const title = `${item
.find('a')
.first()
.text()}`;
const dateRaw = item
.find('td:first-child')
.text()
.trim();
const title = `${item.find('a').first().text()}`;
const dateRaw = item.find('td:first-child').text().trim();
const pubDate = Date.parse(dateRaw) && dateRaw;
const link = item.find('a').attr('href');
return {

View File

@ -29,22 +29,12 @@ module.exports = async (ctx) => {
const audit_status_td = $('td[style="font-weight:100 ;color: black ;position: relative;left:20px"]');
const audit_status = audit_status_td.eq(-1).text();
const title = '【' + audit_status + '】' + $('li.templateTip').text();
const audit_date = audit_status_td
.eq(-1)
.next('td')
.text();
const audit_date = audit_status_td.eq(-1).next('td').text();
let audit_desc = '';
if (audit_status_td.length > 1) {
for (let i = 0; i < audit_status_td.length; i++) {
audit_desc +=
audit_status_td
.eq(i)
.next('td')
.text() +
'' +
audit_status_td.eq(i).text() +
'';
audit_desc += audit_status_td.eq(i).next('td').text() + '' + audit_status_td.eq(i).text() + '';
}
} else {
audit_desc = audit_date + '' + audit_status;

View File

@ -13,10 +13,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(item);
const time = $('li.fbrq').text();
const title = $('li.mc > div').text();
const sub_url = $('li.mc > div')
.find('a')
.attr('href')
.slice(6);
const sub_url = $('li.mc > div').find('a').attr('href').slice(6);
const itemUrl = ori_url + sub_url;
const cache = await ctx.cache.get(itemUrl);
if (cache) {

View File

@ -49,7 +49,7 @@ module.exports = async (ctx) => {
title: 'CTFHub Calendar',
link: 'https://www.ctfhub.com/#/calendar',
description: '提供全网最全最新的 CTF 赛事信息,关注赛事定制自己专属的比赛日历吧。',
item: data.items.map(function(item) {
item: data.items.map(function (item) {
return {
title: item.title,
description: '',

View File

@ -20,10 +20,7 @@ module.exports = async (ctx) => {
description: 'CurseForge文件更新提醒',
item: list
.map((i, item) => ({
title: $(item)
.find('span.table__content.file__name.full')
.text()
.trim(),
title: $(item).find('span.table__content.file__name.full').text().trim(),
description: `<table>
<tr>
<td>FileType</td>
@ -31,30 +28,14 @@ module.exports = async (ctx) => {
<td>FileSize</td>
<td>Download</td></tr>
<tr>
<td>${$(item)
.find('td.project-file__release-type > span')
.attr('title')}</td>
<td>${$(item)
.find('span.table__content.file__name.full')
.text()
.trim()}</td>
<td>${$(item)
.find('span.table__content.file__size')
.text()
.trim()}</td>
<td><a href="${host +
$(item)
.find('td.project-file__actions a')
.attr('href')}">Click Me</a></td>
<td>${$(item).find('td.project-file__release-type > span').attr('title')}</td>
<td>${$(item).find('span.table__content.file__name.full').text().trim()}</td>
<td>${$(item).find('span.table__content.file__size').text().trim()}</td>
<td><a href="${host + $(item).find('td.project-file__actions a').attr('href')}">Click Me</a></td>
</tr>
</table>`,
link: filePage,
pubDate: new Date(
1000 *
$(item)
.find('td.project-file__date-uploaded abbr')
.attr('data-epoch')
).toUTCString(),
pubDate: new Date(1000 * $(item).find('td.project-file__date-uploaded abbr').attr('data-epoch')).toUTCString(),
}))
.get(),
};

View File

@ -29,7 +29,7 @@ module.exports = async (ctx) => {
const storyDetail = await got.get(item.link);
const data = storyDetail.data;
const $ = cheerio.load(data);
$('.article-content img').each(function() {
$('.article-content img').each(function () {
const $img = $(this);
const src = $img.attr('src');

View File

@ -28,7 +28,7 @@ module.exports = async (ctx) => {
const storyDetail = await got.get(item.link);
const data = storyDetail.data;
const $ = cheerio.load(data);
$('.article-content img').each(function() {
$('.article-content img').each(function () {
const $img = $(this);
const src = $img.attr('src');

View File

@ -9,9 +9,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(data);
// 修改 slice 可以获取更多天的内容,暂时最新的一天就够了
const days = $('.sidebar-link:contains(年)')
.slice(0, 1)
.toArray();
const days = $('.sidebar-link:contains(年)').slice(0, 1).toArray();
const items = await Promise.all(
days.map(async (ele) => {

View File

@ -20,9 +20,7 @@ module.exports = {
const data = iconv.decode(listRes.data, 'gb2312');
const $ = cheerio.load(data);
// 只取最近的三个取全文rss
const list = $('li', 'ul')
.slice(0, 3)
.get();
const list = $('li', 'ul').slice(0, 3).get();
const result_item = await Promise.all(
list.map(async (item) => {

View File

@ -76,9 +76,7 @@ module.exports = async (ctx) => {
const liArr = $('li', element);
const date = $('time', element).attr('datetime');
const newLink = $(element)
.attr('href')
.slice(1);
const newLink = $(element).attr('href').slice(1);
// 新闻封面
const cover = $('img', element);
const category = liArr.map((index, li) => $(li).text()).get();

View File

@ -5,7 +5,7 @@ function addPictureAndVideo(item) {
let content = '';
content += item.pictureList
? item.pictureList
.map(function(ele) {
.map(function (ele) {
return `<img src="${ele.picUrl}" />`;
})
.join('<br>')
@ -50,7 +50,7 @@ module.exports = async (ctx) => {
45: '四星半',
50: '五星',
};
const out = data.map(function(item) {
const out = data.map(function (item) {
let link = '';
let title = '';
let content = '';

View File

@ -52,9 +52,7 @@ module.exports = async (ctx) => {
const item = {
title: $('.clearfix h2').text(),
author: $('#avatar_by')
.find('a')
.text(),
author: $('#avatar_by').find('a').text(),
link: itemUrl,
description: $('#article_con').html(),
pubDate: new Date().toUTCString(),

View File

@ -23,9 +23,7 @@ module.exports = async (ctx) => {
const item = {
title: $('.clearfix h2').text(),
author: $('#avatar_by')
.find('a')
.text(),
author: $('#avatar_by').find('a').text(),
link: itemUrl,
description: $('#article_con').html(),
pubDate: new Date().toUTCString(),

View File

@ -36,9 +36,7 @@ module.exports = async (ctx) => {
const item = {
title: $('.clearfix h2').text(),
author: $('#avatar_by')
.find('a')
.text(),
author: $('#avatar_by').find('a').text(),
link: itemUrl,
description: $('#article_con').html(),
pubDate: new Date().toUTCString(),

View File

@ -47,11 +47,7 @@ module.exports = async (ctx) => {
const beforeFilterList = $('div.swiper-container.xfswiper1 > div > div > ul > li > a').get(); // 获取到剧集列表
const list = [];
beforeFilterList.forEach((element) => {
if (
$(element)
.attr('href')
.indexOf('http://') !== -1
) {
if ($(element).attr('href').indexOf('http://') !== -1) {
list.push(element);
}
});

View File

@ -52,9 +52,7 @@ async function load(baseUrl, itemLink, ctx, charset, header) {
}
const $ = cheerio.load(responseData);
// 只抓取论坛1楼消息
const description = $('div#postlist div[id^=post] td[id^=postmessage]')
.slice(0, 1)
.html();
const description = $('div#postlist div[id^=post] td[id^=postmessage]').slice(0, 1).html();
ctx.cache.set(itemLink, description);
return { description };
}
@ -82,10 +80,7 @@ module.exports = async (ctx) => {
let charset = 'utf-8';
for (const attr of contentType.split(';')) {
if (attr.indexOf('charset=') >= 0) {
charset = attr
.split('=')
.pop()
.toLowerCase();
charset = attr.split('=').pop().toLowerCase();
}
}
const responseData =
@ -111,9 +106,7 @@ module.exports = async (ctx) => {
if (version.toUpperCase().startsWith('DISCUZ! 7')) {
// discuz 7.x 系列
// 支持全文抓取限制抓取页面5个
const list = $('tbody[id^="normalthread"] > tr')
.slice(0, 5)
.get();
const list = $('tbody[id^="normalthread"] > tr').slice(0, 5).get();
process = await Promise.all(
list.map(async (item) => {
item = $(item);
@ -130,9 +123,7 @@ module.exports = async (ctx) => {
} else if (version.toUpperCase().startsWith('DISCUZ! X')) {
// discuz X 系列
// 支持全文抓取限制抓取页面5个
const list = $('tbody[id^="normalthread"] > tr')
.slice(0, 5)
.get();
const list = $('tbody[id^="normalthread"] > tr').slice(0, 5).get();
process = await Promise.all(
list.map(async (item) => {
item = $(item);
@ -140,12 +131,7 @@ module.exports = async (ctx) => {
const single = {
title: item.find('a.xst').text(),
link: itemLink,
pubDate: dateUtil(
item
.find('td.by:nth-child(3) em span')
.last()
.text()
),
pubDate: dateUtil(item.find('td.by:nth-child(3) em span').last().text()),
};
const detail = await load(link, itemLink, ctx, charset, header);
return Promise.resolve(Object.assign({}, single, detail));

View File

@ -13,13 +13,9 @@ module.exports = async (ctx) => {
const $ = cheerio.load(res.data);
const link = $('.sidebar-link')
.eq(1)
.attr('href');
const link = $('.sidebar-link').eq(1).attr('href');
const title = $('.site-name').text();
const description = $('a[href="https://javascriptweekly.com/"]')
.parent()
.text();
const description = $('a[href="https://javascriptweekly.com/"]').parent().text();
const articles = await got({
method: 'get',

View File

@ -29,28 +29,18 @@ module.exports = async (ctx) => {
case '':
// 首页轮播
list = $('.focues.hide > ul > li > a').get();
list = list.concat(
$('.fl.w840 > .block > dl > dd > h3 > a')
.slice(0, 7)
.get()
);
list = list.concat($('.fl.w840 > .block > dl > dd > h3 > a').slice(0, 7).get());
break;
case 'ent':
case 'idonews':
// 首页轮播
list = $('ul.zl-top > li > a').get();
list = list.concat(
$('.fl.w840 > .block > dl > dd > h3 > a')
.slice(0, 5)
.get()
);
list = list.concat($('.fl.w840 > .block > dl > dd > h3 > a').slice(0, 5).get());
break;
default:
list = $('.fl.w840 > .block > dl > dd > h3 > a')
.slice(0, 10)
.get();
list = $('.fl.w840 > .block > dl > dd > h3 > a').slice(0, 10).get();
break;
}

View File

@ -14,19 +14,13 @@ module.exports = async (ctx) => {
for (let i = 0; i < list.length; i++) {
const $ = cheerio.load(list[i]);
const score = $('td:nth-of-type(5)')
.text()
.trim();
const score = $('td:nth-of-type(5)').text().trim();
if (score !== '-') {
const time = $('td.match_time_hidden').text();
const type = $('td.gameweek').text();
const home = $('td:nth-of-type(4)')
.text()
.trim();
const away = $('td:nth-of-type(6)')
.text()
.trim();
const home = $('td:nth-of-type(4)').text().trim();
const away = $('td:nth-of-type(6)').text().trim();
const title = `${type} ${home} ${score} ${away}`;
const single = {

View File

@ -10,9 +10,7 @@ module.exports = async (ctx) => {
const host = 'https://www.dongqiudi.com';
const list = $('.detail.special ul li h3')
.slice(0, 5)
.get();
const list = $('.detail.special ul li h3').slice(0, 5).get();
const proList = [];

View File

@ -31,21 +31,8 @@ module.exports = async (ctx) => {
item = $(item);
itemPicUrl = item.find('img').attr('src');
return {
title:
'《' +
item.find('h6 > a').text() +
'》' +
item
.find('h6 > span')
.text()
.replace('(', '')
.replace(')', '')
.replace('[', '【')
.replace(']', '】'),
description: `<img src="${itemPicUrl}"/><br/>主演:${item
.find('dl > dd')
.last()
.text()}<br/>评分${item.find('.star > span:nth-child(2)').text()}`,
title: '《' + item.find('h6 > a').text() + '》' + item.find('h6 > span').text().replace('(', '').replace(')', '').replace('[', '【').replace(']', '】'),
description: `<img src="${itemPicUrl}"/><br/>主演:${item.find('dl > dd').last().text()}<br/>评分:${item.find('.star > span:nth-child(2)').text()}`,
link: item.find('dt > a').attr('href'),
};
})

View File

@ -12,10 +12,7 @@ module.exports = async (ctx) => {
});
let $ = cheerio.load(roomResponse);
const $mod = $('.mod').eq(0);
const title = $mod
.find('.hd > h2 span')
.eq(0)
.text();
const title = $mod.find('.hd > h2 span').eq(0).text();
const newBookUrl = $mod.find('.pl a').attr('href');
const newBookLandingPage = await got({
@ -38,7 +35,7 @@ module.exports = async (ctx) => {
$ = cheerio.load(newBookPage.data);
const resultItem = $('.doulist-item')
.map(function(_, item) {
.map(function (_, item) {
const $item = $(item);
return {

View File

@ -11,76 +11,38 @@ module.exports = async (ctx) => {
const response = await got.get(link);
const $ = cheerio.load(response.data);
const title = $('#content h1')
.text()
.trim();
const description = $('div.doulist-about')
.text()
.trim();
const title = $('#content h1').text().trim();
const description = $('div.doulist-about').text().trim();
const out = $('div.doulist-item')
.slice(0, 10)
.map(function() {
const type = $(this)
.find('div.source')
.text()
.trim();
.map(function () {
const type = $(this).find('div.source').text().trim();
let title = $(this)
.find('div.bd.doulist-note div.title a')
.text()
.trim();
let link = $(this)
.find('div.bd.doulist-note div.title a')
.attr('href');
let description = $(this)
.find('div.bd.doulist-note div.abstract')
.text()
.trim();
let title = $(this).find('div.bd.doulist-note div.title a').text().trim();
let link = $(this).find('div.bd.doulist-note div.title a').attr('href');
let description = $(this).find('div.bd.doulist-note div.abstract').text().trim();
if (type === '来自:豆瓣广播') {
title = $(this)
.find('p.status-content > a')
.text()
.trim();
link = $(this)
.find('p.status-content a')
.attr('href');
title = $(this).find('p.status-content > a').text().trim();
link = $(this).find('p.status-content a').attr('href');
description = $(this)
.find('span.status-recommend-text')
.text()
.trim();
description = $(this).find('span.status-recommend-text').text().trim();
}
if (type === '来自:豆瓣电影' || type === '来自:豆瓣' || type === '来自:豆瓣读书' || type === '来自:豆瓣音乐') {
title = $(this)
.find('div.bd.doulist-subject div.title a')
.text()
.trim();
link = $(this)
.find('div.bd.doulist-subject div.title a')
.attr('href');
title = $(this).find('div.bd.doulist-subject div.title a').text().trim();
link = $(this).find('div.bd.doulist-subject div.title a').attr('href');
description = $(this)
.find('div.bd.doulist-subject div.abstract')
.text()
.trim();
description = $(this).find('div.bd.doulist-subject div.abstract').text().trim();
const ft = $(this)
.find('div.ft div.comment-item.content')
.text()
.trim();
const ft = $(this).find('div.ft div.comment-item.content').text().trim();
const img = $(this)
.find('div.post a img')
.attr('src');
const img = $(this).find('div.post a img').attr('src');
description = '<div><img width="100" src="' + img + '"></div>' + description + '<blockquote>' + ft + '</blockquote>';
}
const date = $(this)
.find('div.ft div.actions time span')
.attr('title');
const date = $(this).find('div.ft div.actions time span').attr('title');
const single = {
title: title,

View File

@ -23,14 +23,8 @@ module.exports = async (ctx) => {
item = $(item);
itemPicUrl = `${item.find('a.cover').attr('style')}`.replace('background-image:url(', '').replace(')', '');
return {
title: item
.find('.title a')
.first()
.text(),
description: `作者:${item
.find('.usr-pic a')
.last()
.text()}<br>描述${item.find('.content p').text()}<br><img src="${itemPicUrl}">`,
title: item.find('.title a').first().text(),
description: `作者:${item.find('.usr-pic a').last().text()}<br>描述:${item.find('.content p').text()}<br><img src="${itemPicUrl}">`,
link: item.find('.title a').attr('href'),
};
})

View File

@ -12,17 +12,11 @@ module.exports = async (ctx) => {
const list = $('div.item')
.slice(0, 10)
.map(function() {
.map(function () {
const info = {
title: $(this)
.find('div.title a')
.text(),
link: $(this)
.find('div.title a')
.attr('href'),
author: $(this)
.find('div.usr-pic a')
.text(),
title: $(this).find('div.title a').text(),
link: $(this).find('div.title a').attr('href'),
author: $(this).find('div.usr-pic a').text(),
};
return info;
})

View File

@ -16,7 +16,7 @@ module.exports = async (ctx) => {
let { content } = topic;
content = content.replace(/ /g, '<br>');
topic.content = content.replace(/<图片(\d*)>/g, function() {
topic.content = content.replace(/<图片(\d*)>/g, function () {
try {
const photo = photos.filter((p) => p.seq_id === arguments[1]);

View File

@ -6,21 +6,13 @@ const url = 'https://book.douban.com/latest';
module.exports = async (ctx) => {
const res = await got.get(url);
const $ = cheerio.load(res.data);
const list = $('#content')
.find('li')
.get();
const list = $('#content').find('li').get();
ctx.state.data = {
title: '豆瓣新书速递',
link: url,
item: list.map((item, index) => ({
title: `${index < 20 ? '[虚构类]' : '[非虚构类]'}${$(item)
.find('h2')
.text()
.trim()}`,
link: $(item)
.find('a')
.first()
.attr('href'),
title: `${index < 20 ? '[虚构类]' : '[非虚构类]'}${$(item).find('h2').text().trim()}`,
link: $(item).find('a').first().attr('href'),
description: $(item).html(),
})),
};

View File

@ -16,12 +16,8 @@ module.exports = async (ctx) => {
title,
link: url,
item: list.map((item) => ({
title: $(item)
.find('.pl2')
.text(),
link: $(item)
.find('.pl2')
.attr('href'),
title: $(item).find('.pl2').text(),
link: $(item).find('.pl2').attr('href'),
description: $(item).html(),
})),
};

View File

@ -47,9 +47,7 @@ async function ProcessFeed(list, caches) {
// the rebounds link is used because all other links in the html could
// possibly point to /signup/new when loading the site while not logged in.
const itemUrlPath = $('.extras > a')
.attr('href')
.replace('/rebounds', '');
const itemUrlPath = $('.extras > a').attr('href').replace('/rebounds', '');
const itemUrl = url.resolve(host, itemUrlPath);
const team = $('.attribution-team').text() ? ' for ' + $('.attribution-team a.url').text() : '';

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