Skip to content

Commit

Permalink
Merge pull request #783 from DIYgod/master
Browse files Browse the repository at this point in the history
[pull] master from diygod:master
  • Loading branch information
pull[bot] authored Feb 6, 2023
2 parents ace844e + 32b92c2 commit cd94a7a
Show file tree
Hide file tree
Showing 28 changed files with 411 additions and 139 deletions.
6 changes: 6 additions & 0 deletions docs/en/study.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ pageClass: routes

<RouteEn author="nczitzk" example="/researchgate/publications/Somsak-Panha" path="/researchgate/publications/:username" :paramsDesc="['Username, can be found in URL']" puppeteer="1" anticrawler="1"/>

## The Korea Institute of Marine Law

### Thesis

<RouteEn author="TonyRL" example="/kimlaw/thesis" path="/kimlaw/thesis" radar="1"/>

## X-MOL

### News
Expand Down
34 changes: 34 additions & 0 deletions docs/government.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,22 @@ pageClass: routes

<Route author="Fatpandac" example="/ssm/news" path="/ssm/news"/>

## 北京社科网

### 通用

<Route author="TonyRL" example="/bjsk/newslist-1394-1474-0" path="/bjsk/:path?" :paramsDesc="['路径,默认为 `newslist-1486-0-0`']" radar="1">

::: tip 提示

路径处填写对应页面 URL 中 `https://www.bjsk.org.cn/``.html` 之间的字段。下面是一个例子。

若订阅 [社科资讯 > 社科要闻](https://www.bjsk.org.cn/newslist-1394-1474-0.html) 则将对应页面 URL <https://www.bjsk.org.cn/newslist-1394-1474-0.html>`https://www.bjsk.org.cn/``.html` 之间的字段 `newslist-1394-1474-0` 作为路径填入。此时路由为 [`/bjsk/newslist-1394-1474-0`](https://rsshub.app/bjsk/newslist-1394-1474-0)

:::

</Route>

## 北京市保障房中心有限公司

### 北京市共有产权住房租赁服务平台
Expand Down Expand Up @@ -98,6 +114,18 @@ pageClass: routes

</Route>

## 北京无线电协会

### 最新资讯

<Route author="Misaka13514" example="/bjwxdxh/114" path="/bjwxdxh/:type?" :paramsDesc="['类型,见下表,默认为全部']" radar="1" rssbud="1">

| 协会活动 | 公告通知 | 会议情况 | 简报 | 政策法规 | 学习园地 | 业余无线电服务中心 | 经验交流 | 新技术推介 | 活动通知 | 爱好者园地 | 结果查询 | 资料下载 | 会员之家 | 会员简介 | 会员风采 | 活动报道 |
| ---- | ---- | ---- | --- | ---- | ---- | --------- | ---- | ----- | ---- | ----- | ---- | ---- | ---- | ---- | ---- | ---- |
| 86 | 99 | 102 | 103 | 106 | 107 | 108 | 111 | 112 | 114 | 115 | 116 | 118 | 119 | 120 | 121 | 122 |

</Route>

## 重庆市人民政府

### 两江新区信息公开网
Expand Down Expand Up @@ -1038,6 +1066,12 @@ pageClass: routes

</Route>

## 中国科学技术协会

### 通用

<Route author="TonyRL" example="/cast" path="/cast/:column?" :paramsDesc="['栏目 ID,即 URL 中的数字,默认为 `457`']" radar="1"/>

## 中国农工民主党

### 新闻中心
Expand Down
6 changes: 3 additions & 3 deletions docs/picture.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,15 @@ pageClass: routes

### 收藏

<Route author="yindaheng98" example="/ehentai/favorites/0/posted/1" path="/ehentai/favorites/:favcat?/:order?/:page?/:routeParams?" :paramsDesc="['收藏夹编号','顺序:posted-按画廊发布时间排序,favorited-按添加收藏的时间排序', '爬获取第多少页的数据', '额外参数;请参阅上面的说明和表格']" anticrawler="1" supportBT="1" />
<Route author="yindaheng98" example="/ehentai/favorites/0/posted" path="/ehentai/favorites/:favcat?/:order?/:page?/:routeParams?" :paramsDesc="['收藏夹编号','顺序:posted-按画廊发布时间排序,favorited-按添加收藏的时间排序', '翻页参数,对应E站地址中的next参数', '额外参数;请参阅上面的说明和表格']" anticrawler="1" supportBT="1" />

### 标签

<Route author="yindaheng98" example="/ehentai/tag/language:chinese/1" path="/ehentai/tag/:tag/:page?/:routeParams?" :paramsDesc="['标签', '爬获取第多少页的数据', '额外参数;请参阅上面的说明和表格']" anticrawler="1" supportBT="1" />
<Route author="yindaheng98" example="/ehentai/tag/language:chinese" path="/ehentai/tag/:tag/:page?/:routeParams?" :paramsDesc="['标签', '翻页参数,对应E站地址中的next参数', '额外参数;请参阅上面的说明和表格']" anticrawler="1" supportBT="1" />

### 搜索

<Route author="yindaheng98" example="/ehentai/search/f_search=artist%3Amana%24/1" path="/ehentai/search/:params?/:page?/:routeParams?" :paramsDesc="['用于搜索的关键词。可在原网站搜索后复制 `https://e-hentai.org/?` 后面的内容', '爬获取第多少页的数据', '额外参数;请参阅上面的说明和表格']" anticrawler="1" supportBT="1" />
<Route author="yindaheng98" example="/ehentai/search/f_search=artist%3Amama%24" path="/ehentai/search/:params?/:page?/:routeParams?" :paramsDesc="['用于搜索的关键词。可在原网站搜索后复制 `https://e-hentai.org/?` 后面的内容', '翻页参数,对应E站地址中的next参数', '额外参数;请参阅上面的说明和表格']" anticrawler="1" supportBT="1" />

## Elite Babes

Expand Down
6 changes: 6 additions & 0 deletions docs/study.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,12 @@ path="/ctfhub/upcoming/:limit?"

</Route>

## 韓國海事法學會

### 学术论文

<Route author="TonyRL" example="/kimlaw/thesis" path="/kimlaw/thesis" radar="1"/>

## 杭州市国家普通话测试网报信息

### 考试信息
Expand Down
52 changes: 52 additions & 0 deletions lib/v2/bjsk/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');

const baseUrl = 'https://www.bjsk.org.cn';

module.exports = async (ctx) => {
const { path = 'newslist-1486-0-0' } = ctx.params;
const link = `${baseUrl}/${path}.html`;
const { data: response } = await got(link, {
https: {
rejectUnauthorized: false,
},
});
const $ = cheerio.load(response);

const list = $('.article-list a')
.toArray()
.map((item) => {
item = $(item);
return {
title: item.attr('title'),
link: `${baseUrl}${item.attr('href')}`,
pubDate: parseDate(item.find('.time').text(), 'YYYY.MM.DD'),
};
});

const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link, {
https: {
rejectUnauthorized: false,
},
});
const $ = cheerio.load(response);
item.description = $('.article-main').html();
item.author = $('.info')
.text()
.match(/(.*)\s+/)[1];
return item;
})
)
);

ctx.state.data = {
title: $('head title').text(),
link,
image: 'https://www.bjsk.org.cn/favicon.ico',
item: items,
};
};
3 changes: 3 additions & 0 deletions lib/v2/bjsk/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/:path?': ['TonyRL'],
};
13 changes: 13 additions & 0 deletions lib/v2/bjsk/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
'bjsk.org.cn': {
_name: '北京社科网',
'.': [
{
title: '通用',
docs: 'https://docs.rsshub.app/government.html#bei-jing-she-ke-wang',
source: ['/*'],
target: (_, url) => `/bjsk/${url.split('/')[3].replace('.html', '')}`,
},
],
},
};
3 changes: 3 additions & 0 deletions lib/v2/bjsk/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = (router) => {
router.get('/:path?', require('./index'));
};
52 changes: 52 additions & 0 deletions lib/v2/bjwxdxh/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
const cheerio = require('cheerio');
const got = require('@/utils/got');
const timezone = require('@/utils/timezone');
const { parseDate } = require('@/utils/parse-date');

module.exports = async (ctx) => {
const baseUrl = 'http://www.bjwxdxh.org.cn';
const type = ctx.params.type;
const link = type ? `${baseUrl}/news/class/?${type}.html` : `${baseUrl}/news/class/`;

const response = await got({
method: 'get',
url: link,
});

const $ = cheerio.load(response.data);
const list = $('div#newsquery > ul > li')
.map((_, item) => {
item = $(item);
return {
title: item.find('div.title > a').text(),
link: new URL(item.find('div.title > a').attr('href'), baseUrl).href,
// pubDate: parseDate(item.find('div.time').text(), 'YYYY-MM-DD'),
};
})
.get();

await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const response = await got({
method: 'get',
url: item.link,
});
const content = cheerio.load(response.data);
const info = content('div.info')
.text()
.match(/(.*?)\s+(.*?\s+.*?)\s/);
item.author = info[1];
item.pubDate = timezone(parseDate(info[2], 'YYYY-MM-DD HH:mm:ss'), +8);
item.description = content('div#con').html().trim().replace(/\n/g, '');
return item;
})
)
);

ctx.state.data = {
title: $('title').text(),
link,
item: list,
};
};
3 changes: 3 additions & 0 deletions lib/v2/bjwxdxh/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/:type?': ['Misaka13514'],
};
13 changes: 13 additions & 0 deletions lib/v2/bjwxdxh/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
'bjwxdxh.org.cn': {
_name: '北京无线电协会',
www: [
{
title: '最新资讯',
docs: 'https://docs.rsshub.app/government.html#bei-jing-wu-xian-dian-xie-hui',
source: '/news/class/',
target: (params, url) => (url.includes('?') ? `/bjwxdxh/${url.split('?')[1].split('.')[0]}` : '/bjwxdxh'),
},
],
},
};
3 changes: 3 additions & 0 deletions lib/v2/bjwxdxh/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/:type?', require('./index'));
};
74 changes: 74 additions & 0 deletions lib/v2/cast/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
const timezone = require('@/utils/timezone');
const baseUrl = 'https://www.cast.org.cn';

module.exports = async (ctx) => {
const { column = 457 } = ctx.params;
const { limit = 10 } = ctx.query;
const link = `${baseUrl}/col/col${column}/index.html`;
const { data: response } = await got.post(`${baseUrl}/module/web/jpage/dataproxy.jsp`, {
searchParams: {
startrecord: 1,
endrecord: limit,
perpage: limit,
},
form: {
col: 1,
appid: 1,
webid: 1,
path: '/',
columnid: column,
sourceContentType: 1,
unitid: 335,
webname: '中国科学技术协会',
permissiontype: 0,
},
});

const $ = cheerio.load(response, {
xml: {
xmlMode: true,
},
});

const pageTitle = await ctx.cache.tryGet(link, async () => {
const { data: response } = await got(link);
const $ = cheerio.load(response);
return $('head title').text();
});

const list = $('record')
.toArray()
.map((item) => {
item = cheerio.load($(item).html(), null, false);
const a = item('a').first();
return {
title: a.text(),
pubDate: parseDate(item('.list-data').text().trim(), 'DDYYYY/MM'),
link: `${baseUrl}${a.attr('href')}`,
};
});

const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = cheerio.load(response);

item.description = $('#zoom').html();
item.pubDate = timezone(parseDate($('meta[name=PubDate]').attr('content'), 'YYYY-MM-DD HH:mm'), +8);

return item;
})
)
);

ctx.state.data = {
title: pageTitle,
link,
image: 'https://www.cast.org.cn/favicon.ico',
item: items,
};
};
3 changes: 3 additions & 0 deletions lib/v2/cast/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/:column?': ['TonyRL'],
};
13 changes: 13 additions & 0 deletions lib/v2/cast/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
'cast.org.cn': {
_name: '中国科学技术协会',
'.': [
{
title: '通用',
docs: 'https://docs.rsshub.app/government.html#zhong-guo-ke-xue-ji-shu-xie-hui',
source: ['/col/:column/index.html'],
target: (params) => `/cast/${params.column.replace('col', '')}`,
},
],
},
};
3 changes: 3 additions & 0 deletions lib/v2/cast/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = (router) => {
router.get('/:column?', require('./index'));
};
15 changes: 10 additions & 5 deletions lib/v2/ehentai/ehapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,25 +192,30 @@ async function gatherItemsByPage(cache, url, get_bittorrent = false, embed_thumb
return updateBittorrent_url(cache, items);
}

async function getFavoritesItems(cache, page, favcat, inline_set, get_bittorrent = false, embed_thumb = false) {
async function getFavoritesItems(cache, favcat, inline_set, page = undefined, get_bittorrent = false, embed_thumb = false) {
const response = await ehgot(`favorites.php?favcat=${favcat}&inline_set=${inline_set}`);
if (parseInt(page) === 0) {
if (page) {
return gatherItemsByPage(cache, `favorites.php?favcat=${favcat}&next=${page}`, get_bittorrent, embed_thumb);
} else {
const items = await parsePage(cache, response.data, get_bittorrent, embed_thumb);
return updateBittorrent_url(cache, items);
}
return gatherItemsByPage(cache, `favorites.php?page=${page}&favcat=${favcat}`, get_bittorrent, embed_thumb);
}

function getSearchItems(cache, params, page = undefined, get_bittorrent = false, embed_thumb = false) {
if (page) {
return gatherItemsByPage(cache, `?page=${page}&${params}`, get_bittorrent, embed_thumb);
return gatherItemsByPage(cache, `?${params}&next=${page}`, get_bittorrent, embed_thumb);
} else {
return gatherItemsByPage(cache, `?${params}`, get_bittorrent, embed_thumb);
}
}

function getTagItems(cache, tag, page, get_bittorrent = false, embed_thumb = false) {
return gatherItemsByPage(cache, `tag/${tag}/${page}`, get_bittorrent, embed_thumb);
if (page) {
return gatherItemsByPage(cache, `tag/${tag}?next=${page}`, get_bittorrent, embed_thumb);
} else {
return gatherItemsByPage(cache, `tag/${tag}`, get_bittorrent, embed_thumb);
}
}

module.exports = { getFavoritesItems, getSearchItems, getTagItems, has_cookie, from_ex };
4 changes: 2 additions & 2 deletions lib/v2/ehentai/favorites.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ module.exports = async (ctx) => {
throw 'Ehentai favorites RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>';
}
const favcat = ctx.params.favcat ? parseInt(ctx.params.favcat) : 0;
const page = ctx.params.page ? parseInt(ctx.params.page) : 0;
const page = ctx.params.page;
const routeParams = new URLSearchParams(ctx.params.routeParams);
const bittorrent = routeParams.get('bittorrent') || false;
const embed_thumb = routeParams.get('embed_thumb') || false;
const inline_set = ctx.params.order === 'posted' ? 'fs_p' : 'fs_f';
const items = await EhAPI.getFavoritesItems(ctx.cache, page, favcat, inline_set, bittorrent, embed_thumb);
const items = await EhAPI.getFavoritesItems(ctx.cache, favcat, inline_set, page, bittorrent, embed_thumb);

if (EhAPI.from_ex) {
ctx.state.data = {
Expand Down
Loading

1 comment on commit cd94a7a

@vercel
Copy link

@vercel vercel bot commented on cd94a7a Feb 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.