Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(route): add route for Society journals #17899

Merged
merged 7 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions lib/routes/society/current.ts
Original file line number Diff line number Diff line change
@@ -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`;
CNYoki marked this conversation as resolved.
Show resolved Hide resolved
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,
CNYoki marked this conversation as resolved.
Show resolved Hide resolved
};
}
return null;
})
.filter((item) => item !== null);

return {
title: `《社会》期刊当期目录`,
CNYoki marked this conversation as resolved.
Show resolved Hide resolved
link: url,
item: items,
};
}
11 changes: 11 additions & 0 deletions lib/routes/society/namespace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { Namespace } from '@/types';
CNYoki marked this conversation as resolved.
Show resolved Hide resolved

export const namespace: Namespace = {
name: '《社会》期刊',
url: 'www.society.shu.edu.cn',
description: '《社会》期刊当期目录',
lang: 'zh-CN',
zh: {
name: '《社会》期刊',
},
};
Loading