Skip to content

Commit

Permalink
fix routes according to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
CNYoki committed Dec 17, 2024
1 parent a3600d7 commit 8cd008e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
20 changes: 13 additions & 7 deletions lib/routes/society/current.ts → lib/routes/shu/society.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Route } from '@/types';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';

export const route: Route = {
path: '/current',
path: '/journals/society/current',
categories: ['journal'],
example: '/current',
example: '/journals/society/current',
features: {
requireConfig: false,
requirePuppeteer: false,
Expand All @@ -14,16 +15,22 @@ export const route: Route = {
supportPodcast: false,
supportScihub: false,
},
name: '《社会》期刊当期目录',
name: '《社会》杂志当期目录',
maintainers: ['CNYoki'],
handler,
};

async function handler() {
const url = `https://www.society.shu.edu.cn/CN/1004-8804/current.shtml`;
const url = 'https://www.society.shu.edu.cn/CN/1004-8804/current.shtml';
const response = await got(url);
const $ = load(response.body);

// 提取刊出日期
const pubDateText = $('.dqtab .njq')
.text()
.match(/刊出日期:(\d{4}-\d{2}-\d{2})/);
const pubDate = pubDateText ? parseDate(pubDateText[1]) : null;

const items = $('.wenzhanglanmu')
.nextAll('.noselectrow')
.toArray()
Expand All @@ -32,7 +39,6 @@ async function handler() {
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) {
Expand All @@ -41,15 +47,15 @@ async function handler() {
link: links,
description: abstract,
author: authors,
date,
pubDate,
};
}
return null;
})
.filter((item) => item !== null);

return {
title: `《社会》期刊当期目录`,
title: '《社会》当期目录',
link: url,
item: items,
};
Expand Down
11 changes: 0 additions & 11 deletions lib/routes/society/namespace.ts

This file was deleted.

0 comments on commit 8cd008e

Please sign in to comment.