fix(route/nature): nature research route

This commit is contained in:
pseudoyu
2024-10-29 22:17:13 +07:00
parent 8adffd26e8
commit 0ebc981e89
2 changed files with 6 additions and 8 deletions
+1 -1
View File
@@ -38,7 +38,7 @@ export const route: Route = {
},
],
name: 'Latest Research',
maintainers: ['y9c', 'TonyRL'],
maintainers: ['y9c', 'TonyRL', 'pseudoyu'],
handler,
description: `| \`:journal\` | Full Name of the Journal | Route |
| :-----------: | :-------------------------: | ---------------------------------------------------------------------------------- |
+5 -7
View File
@@ -1,5 +1,5 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import ofetch from '@/utils/ofetch';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
import { CookieJar } from 'tough-cookie';
@@ -52,13 +52,11 @@ const getArticleList = (html) =>
const getArticle = (item) =>
cache.tryGet(item.link, async () => {
const response = await got(item.link, {
cookieJar,
});
const $ = load(response.data);
const responseUrl = new URL(response.url);
const response = await ofetch(item.link);
if (responseUrl.pathname.startsWith('/immersive/')) {
const $ = load(response);
if (new URL(item.link).pathname.startsWith('/immersive/')) {
const meta = getDataLayer($);
item.doi = meta.content.article?.doi;
item.author = meta.content.contentInfo.authors.join(', ');