diff --git a/lib/routes/pocket/trending.js b/lib/routes/pocket/trending.js index 83736c9eb..c03c69fc8 100644 --- a/lib/routes/pocket/trending.js +++ b/lib/routes/pocket/trending.js @@ -7,19 +7,24 @@ module.exports = async (ctx) => { const response = await got.get(url); const $ = cheerio.load(response.data); - const list = $('.item').toArray(); - + const list = $('article').get(); ctx.state.data = { title: 'Trending on Pocket', description: 'Top Articles and Videos about Trending on Pocket', link: url, item: list.map((item) => { item = $(item); + const middle_link = new URL(item.find('a').first().attr('href')); + const media = item + .find('.media') + .attr('style') + .match(/url\('(.*?)'\);/)[1]; + const pic_html = media ? `` : ''; return { title: item.find('.title').text(), - author: item.find('.domain > a').text(), - description: `

${item.find('.excerpt').text()}

`, - link: item.find('.item_link').attr('data-saveurl'), + author: item.find('.details > span').first().text(), + description: `

${item.find('.excerpt').text()}

` + pic_html, + link: middle_link.searchParams.get('url') || middle_link.href, }; }), };