From a3600d7f26fc8c4e4c0dca6192a1b52b4ffe48cd Mon Sep 17 00:00:00 2001 From: CNYoki Date: Mon, 16 Dec 2024 11:54:26 +0800 Subject: [PATCH] Add router for society issues --- lib/routes/society/current.ts | 56 +++++++++++++++++++++++++++++++++ lib/routes/society/namespace.ts | 11 +++++++ 2 files changed, 67 insertions(+) create mode 100644 lib/routes/society/current.ts create mode 100644 lib/routes/society/namespace.ts diff --git a/lib/routes/society/current.ts b/lib/routes/society/current.ts new file mode 100644 index 00000000000000..0c3ec0ed23ad5c --- /dev/null +++ b/lib/routes/society/current.ts @@ -0,0 +1,56 @@ +import { Route } from '@/types'; +import got from '@/utils/got'; +import { load } from 'cheerio'; + +export const route: Route = { + path: '/current', + categories: ['journal'], + example: '/current', + features: { + requireConfig: false, + requirePuppeteer: false, + antiCrawler: false, + supportBT: false, + supportPodcast: false, + supportScihub: false, + }, + name: '《社会》期刊当期目录', + maintainers: ['CNYoki'], + handler, +}; + +async function handler() { + const url = `https://www.society.shu.edu.cn/CN/1004-8804/current.shtml`; + const response = await got(url); + const $ = load(response.body); + + const items = $('.wenzhanglanmu') + .nextAll('.noselectrow') + .toArray() + .map((item) => { + const $item = $(item); + const titles = $item.find('.biaoti').text().trim(); + const links = $item.find('.biaoti').attr('href'); + const authors = $item.find('.zuozhe').text().trim(); + const date = $item.find('.kmnjq').text().trim(); + const abstract = $item.find('div[id^="Abstract"]').text().trim(); + + if (titles && links) { + return { + title: titles, + link: links, + description: abstract, + author: authors, + date, + }; + } + return null; + }) + .filter((item) => item !== null); + + return { + title: `《社会》期刊当期目录`, + link: url, + item: items, + }; +} diff --git a/lib/routes/society/namespace.ts b/lib/routes/society/namespace.ts new file mode 100644 index 00000000000000..5bb67020e8ada4 --- /dev/null +++ b/lib/routes/society/namespace.ts @@ -0,0 +1,11 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '《社会》期刊', + url: 'www.society.shu.edu.cn', + description: '《社会》期刊当期目录', + lang: 'zh-CN', + zh: { + name: '《社会》期刊', + }, +};