diff --git a/lib/v2/bioone/featured.js b/lib/v2/bioone/featured.js index 80b8a7746..2e95f3da3 100644 --- a/lib/v2/bioone/featured.js +++ b/lib/v2/bioone/featured.js @@ -4,9 +4,10 @@ const { parseDate } = require('@/utils/parse-date'); module.exports = async (ctx) => { const rootUrl = 'https://bioone.org'; - const response = await got({ - method: 'get', - url: rootUrl, + const response = await got(rootUrl, { + https: { + rejectUnauthorized: false, + }, }); const $ = cheerio.load(response.data); @@ -16,20 +17,21 @@ module.exports = async (ctx) => { .toArray() .map((item) => { item = $(item); - const link = item.attr('href'); + const link = item.attr('href').split('?')[0]; return { title: item.text(), - link: link.indexOf('http') < 0 ? `${rootUrl}${link}` : link, + link: !link.includes('http') ? `${rootUrl}${link}` : link, }; }); items = await Promise.all( items.map((item) => ctx.cache.tryGet(item.link, async () => { - const detailResponse = await got({ - method: 'get', - url: item.link, + const detailResponse = await got(item.link, { + https: { + rejectUnauthorized: false, + }, }); const content = cheerio.load(detailResponse.data); diff --git a/lib/v2/bioone/journal.js b/lib/v2/bioone/journal.js index e6faaaf4d..6e2a5cad1 100644 --- a/lib/v2/bioone/journal.js +++ b/lib/v2/bioone/journal.js @@ -7,15 +7,16 @@ module.exports = async (ctx) => { const rootUrl = 'https://bioone.org'; const currentUrl = `${rootUrl}/journals/${journal}/current`; - const response = await got({ - method: 'get', - url: currentUrl, + const response = await got(currentUrl, { + https: { + rejectUnauthorized: false, + }, }); const $ = cheerio.load(response.data); let items = $('.TOCLineItemBoldText') - .slice(0, ctx.query.limit ? parseInt(ctx.query.limit) : 10) + .slice(0, ctx.query.limit ? parseInt(ctx.query.limit) : 20) .toArray() .map((item) => { item = $(item).parent(); @@ -29,9 +30,10 @@ module.exports = async (ctx) => { items.map( async (item) => await ctx.cache.tryGet(item.link, async () => { - const detailResponse = await got({ - method: 'get', - url: item.link, + const detailResponse = await got(item.link, { + https: { + rejectUnauthorized: false, + }, }); const content = cheerio.load(detailResponse.data); @@ -51,7 +53,8 @@ module.exports = async (ctx) => { ); ctx.state.data = { - title: `${response.data.match(/'journalpaper', '(.*)'\)\\" class=\\"/)[1]} - BioOne`, + title: `${$('.panel-body .row a').first().text()} - BioOne`, + description: $('.panel-body .row text').first().text(), link: currentUrl, item: items, };