Skip to content

Commit

Permalink
feat(route): add route of 深圳福田园岭小学 (#16876)
Browse files Browse the repository at this point in the history
* Create namespace.ts

* Add files via upload

* Update dongtai.ts

* Update gonggao.ts

* Update gonggao.ts

* Update gonggao.ts

* Update dongtai.ts

* Update gonggao.ts

* Update gonggao.ts

* Update gonggao.ts

* Update gonggao.ts

* Update dongtai.ts

* Create namespace.ts

* Add files via upload

* Update articles.ts

* Update articles.ts

* Update articles.ts

* Update articles.ts

* Update articles.ts

* Update articles.ts

* Update articles.ts

* route for 日经新闻半导体,产业聚焦

* Update scienceatechnology.ts

* Update semi.ts

* Delete lib/routes/yamap directory

* Delete lib/routes/nikkei/semi.ts

* Delete lib/routes/nikkei/scienceatechnology.ts

* Update lib/routes/szftedu/dongtai.ts

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update lib/routes/szftedu/namespace.ts

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update lib/routes/szftedu/gonggao.ts

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update gonggao.ts

* Update gonggao.ts

* Update dongtai.ts

* Update gonggao.ts

* Update gonggao.ts

* Update dongtai.ts

* Update dongtai.ts

* Update dongtai.ts

* Update gonggao.ts

* Update lib/routes/szftedu/gonggao.ts

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update lib/routes/szftedu/dongtai.ts

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update dongtai.ts

* Update dongtai.ts

* fix: route name

---------
  • Loading branch information
valuex authored Sep 28, 2024
1 parent b5152c0 commit b79a524
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 0 deletions.
62 changes: 62 additions & 0 deletions lib/routes/szftedu/dongtai.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { Route } from '@/types';
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
import timezone from '@/utils/timezone';

const host = 'https://ylxx.szftedu.cn/xx_5828/xydt_5829/bxfbx_6371/';
const baseLink = 'https://ylxx.szftedu.cn';

export const route: Route = {
path: '/dongtai',
categories: ['university'],
example: '/szftedu/dongtai',
parameters: {},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
name: '动态',
maintainers: ['valuex'],
handler,
description: '',
};

async function handler() {
const link = host;
const response = await got(link);
const $ = load(response.data);
const lists = $('div.pagenews04 div ul li')
.toArray()
.map((el) => ({
title: $('a', el).text().trim(),
link: $('a', el).attr('href'),
pubDate: timezone(parseDate($('span[class=canedit]', el).text()), 8),
}));

const items = await Promise.all(
lists.map((item) =>
cache.tryGet(item.link, async () => {
const thisUrl = item.link;
const trueLink = thisUrl.includes('http') ? thisUrl : baseLink + thisUrl;
const response = await got(trueLink);
const $ = load(response.data);
item.description = thisUrl.includes('http') ? $('#page-content').html() : $('div.TRS_Editor').html();
item.pubDate = timezone(parseDate($('#publish_time').first().text()), 8);
return item;
})
)
);

return {
title: '园岭小学动态',
link: host,
description: '园岭小学动态',
item: items,
};
}
62 changes: 62 additions & 0 deletions lib/routes/szftedu/gonggao.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { Route } from '@/types';
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
import timezone from '@/utils/timezone';

const host = 'https://ylxx.szftedu.cn/xx_5828/xygg_5832/';

export const route: Route = {
path: '/gonggao',
categories: ['university'],
example: '/szftedu/gonggao',
parameters: {},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
name: '公告',
maintainers: ['valuex'],
handler,
description: '',
};

async function handler() {
const link = host;
const response = await got(link);
const $ = load(response.data);

const lists = $('div.pagenews04 div ul li')
.toArray()
.map((el) => ({
title: $('a', el).text().trim(),
link: $('a', el).attr('href'),
pubDate: timezone(parseDate($('span[class=canedit]', el).text()), 8),
}));

const items = await Promise.all(
lists.map((item) =>
cache.tryGet(item.link, async () => {
const thisUrl = item.link;
const trueLink = thisUrl.includes('http') ? thisUrl : host + thisUrl.substring(1);
const response = await got(trueLink);
const $ = load(response.data);
item.description = thisUrl.includes('http') ? $('#page-content').html() : $('div.TRS_Editor').html();
item.pubDate = timezone(parseDate($('.item').first().text().replace('发布时间:', '')), 8);
return item;
})
)
);

return {
title: '园岭小学公告',
link: host,
description: '园岭小学公告',
item: items,
};
}
6 changes: 6 additions & 0 deletions lib/routes/szftedu/namespace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { Namespace } from '@/types';

export const namespace: Namespace = {
name: '园岭小学',
url: 'ylxx.szftedu.cn',
};

0 comments on commit b79a524

Please sign in to comment.