From d24101e8ff71ab78d67e35a54db9c050d303d255 Mon Sep 17 00:00:00 2001 From: cnk Date: Tue, 25 Mar 2025 15:27:51 +0800 Subject: [PATCH] fix(routes/academia): adapt to new design (#18684) --- lib/routes/academia/topics.ts | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/lib/routes/academia/topics.ts b/lib/routes/academia/topics.ts index f1981a6af..c45c9937c 100644 --- a/lib/routes/academia/topics.ts +++ b/lib/routes/academia/topics.ts @@ -13,7 +13,7 @@ export const route: Route = { }, ], name: 'interest', - maintainers: ['K33k0'], + maintainers: ['K33k0', 'cscnk52'], categories: ['journal'], handler, url: 'academia.edu', @@ -21,29 +21,19 @@ export const route: Route = { async function handler(ctx) { const interest = ctx.req.param('interest'); - const response = await ofetch(`https://www.academia.edu/Documents/in/${interest}/MostRecent`); + const response = await ofetch(`https://www.academia.edu/Documents/in/${interest}`); const $ = load(response); - const list = $('.works > .u-borderBottom1') + const list = $('.works > .div') .toArray() - .map((item) => { - const tagsElem = $(item).find('li.InlineList-item.u-positionRelative > span > script').text().replaceAll('}{', '},{'); - let categories = []; - if (tagsElem !== null) { - const categoriesJSON = JSON.parse(`[${tagsElem}]`); - categories = categoriesJSON.map((category) => category.name); - } - - return { - title: $(item).find('.header .title').text(), - link: $(item).find('.header .title > a').attr('href'), - author: $(item).find('span[itemprop=author] > a').text(), - description: $(item).find('.complete').text(), - category: categories, - }; - }); + .map((item) => ({ + title: $(item).find('.title').text(), + link: $(item).find('.title > a').attr('href'), + author: $(item).find('.authors').text().replace('by', '').trim(), + description: $(item).find('.summarized').text(), + })); return { title: `academia.edu | ${interest} documents`, - link: `https://academia.edu/Documents/in/${interest}/MostRecent`, + link: `https://academia.edu/Documents/in/${interest}`, item: list, }; }