Skip to content

Commit

Permalink
Merge pull request #22 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 May 18, 2024
2 parents dcf662e + 1b78fce commit b558d4f
Show file tree
Hide file tree
Showing 51 changed files with 499 additions and 477 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,3 @@ package-lock.json
# pnpm-lock.yaml
yarn.lock
yarn-error.log

scripts/twitter-token/accounts.*
14 changes: 3 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
[![test](https://img.shields.io/github/actions/workflow/status/DIYgod/RSSHub/test.yml?branch=master&label=test&logo=github&style=flat-square)](https://github.com/DIYgod/RSSHub/actions/workflows/test.yml?query=event%3Apush+branch%3Amaster)
[![Test coverage](https://img.shields.io/codecov/c/github/DIYgod/RSSHub.svg?style=flat-square&logo=codecov)](https://app.codecov.io/gh/DIYgod/RSSHub/branch/master)

[![Telegram group](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fapi.swo.moe%2Fstats%2Ftelegram%2Frsshub&query=count&color=2CA5E0&label=Telegram%20Group&logo=telegram&cacheSeconds=3600&style=flat-square)](https://t.me/rsshub) [![Telegram channel](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fapi.swo.moe%2Fstats%2Ftelegram%2FawesomeRSSHub&query=count&color=2CA5E0&label=Telegram%20Channel&logo=telegram&cacheSeconds=3600&style=flat-square)](https://t.me/awesomeRSSHub) [![Twitter](https://img.shields.io/badge/any_text-Follow-blue?color=2CA5E0&label=Twitter&logo=twitter&cacheSeconds=3600&style=flat-square)](https://twitter.com/intent/follow?screen_name=_RSSHub)
[![Telegram group](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fapi.swo.moe%2Fstats%2Ftelegram%2Frsshub&query=count&color=2CA5E0&label=Telegram%20Group&logo=telegram&cacheSeconds=3600&style=flat-square)](https://t.me/rsshub) [![Telegram channel](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fapi.swo.moe%2Fstats%2Ftelegram%2FawesomeRSSHub&query=count&color=2CA5E0&label=Telegram%20Channel&logo=telegram&cacheSeconds=3600&style=flat-square)](https://t.me/awesomeRSSHub) [![Twitter](https://img.shields.io/badge/any_text-Follow-blue?color=2CA5E0&label=Twitter&logo=twitter&cacheSeconds=3600&style=flat-square)](https://x.com/intent/follow?screen_name=_RSSHub)

## Introduction

Expand All @@ -21,18 +21,10 @@ RSSHub delivers millions of contents aggregated from all kinds of sources, our v

RSSHub can be used with browser extension [RSSHub Radar](https://github.com/DIYgod/RSSHub-Radar) and mobile auxiliary app [RSSBud](https://github.com/Cay-Zhang/RSSBud) (iOS) and [RSSAid](https://github.com/LeetaoGoooo/RSSAid) (Android)

[English docs](https://docs.rsshub.app) | [Telegram Group](https://t.me/rsshub) | [Telegram Channel](https://t.me/awesomeRSSHub) | [Twitter](https://twitter.com/intent/follow?screen_name=_RSSHub) | [中文文档](https://docs.rsshub.app/zh/)
[English docs](https://docs.rsshub.app) | [Telegram Group](https://t.me/rsshub) | [Telegram Channel](https://t.me/awesomeRSSHub) | [Twitter](https://x.com/intent/follow?screen_name=_RSSHub) | [中文文档](https://docs.rsshub.app/zh/)

## Special Thanks

### Special Sponsors

<p>
<a href="https://rss3.io" target="_blank"><img height="50px" src="https://i.imgur.com/lb1dDGK.png"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://xlog.app/" target="_blank"><img height="50px" src="https://i.imgur.com/JuhHTKD.png"></a>
</p>

[![](https://opencollective.com/static/images/become_sponsor.svg)](https://docs.rsshub.app/sponsor/)

### Contributors

[![](https://opencollective.com/RSSHub/contributors.svg?width=890)](https://github.com/DIYgod/RSSHub/graphs/contributors)
Expand Down Expand Up @@ -99,4 +91,4 @@ Open source is a very expensive thing. RSSHub would not be possible without the
**RSSHub** © [DIYgod](https://github.com/DIYgod), Released under the [MIT](./LICENSE) License.<br>
Authored and maintained by DIYgod with help from contributors ([list](https://github.com/DIYgod/RSSHub/contributors)).

> Blog [@DIYgod](https://diygod.cc) · GitHub [@DIYgod](https://github.com/DIYgod) · Twitter [@DIYgod](https://twitter.com/DIYgod) · Telegram Channel [@awesomeDIYgod](https://t.me/awesomeDIYgod)
> Blog [@DIYgod](https://diygod.cc) · GitHub [@DIYgod](https://github.com/DIYgod) · Twitter [@DIYgod](https://x.com/DIYgod) · Telegram Channel [@awesomeDIYgod](https://t.me/awesomeDIYgod)
100 changes: 68 additions & 32 deletions lib/routes/81/81rc/index.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,35 @@
import { Route } from '@/types';
import { getSubPath } from '@/utils/common-utils';

import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
import { parseDate } from '@/utils/parse-date';

export const route: Route = {
path: '/81rc/*',
name: 'Unknown',
maintainers: [],
handler,
};

async function handler(ctx) {
const thePath = getSubPath(ctx).replace(/^\/81rc/, '');
export const handler = async (ctx) => {
const { category = 'sy/gzdt_210283' } = ctx.req.param();
const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 30;

const rootUrl = 'https://81rc.81.cn';

// The default is http://81rc.81.cn/sy/gzdt_210283.
const currentUrl = new URL(thePath || '/sy/gzdt_210283', rootUrl).href;
const currentUrl = new URL(category?.endsWith('/') ? `${category}/` : category, rootUrl).href;

const { data: response } = await got(currentUrl);

const $ = load(response);

let items = $('div.left-news ul li a')
const language = $('html').prop('lang');

let items = $('div.left-news ul li')
.slice(0, limit)
.toArray()
.map((item) => {
item = $(item);

return {
title: item.text(),
link: new URL(item.prop('href'), rootUrl).href,
pubDate: timezone(parseDate(item.parent().find('span').text()), +8),
title: item.find('a').text(),
pubDate: timezone(parseDate(item.find('span').text()), +8),
link: item.find('a').prop('href'),
language,
};
});

Expand All @@ -44,29 +38,71 @@ async function handler(ctx) {
cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);

const content = load(detailResponse);
const $$ = load(detailResponse);

item.description = content('.txt').html();
item.author = content('meta[name="reporter"]').prop('content') || content('meta[name="author"]').prop('content');
const description = $$('div.txt').html();

item.title = $$('h2').text();
item.description = description;
item.pubDate = timezone(parseDate($$('div.time span').last().text()), +8);
item.author = $$('div.time span').first().text();
item.content = {
html: description,
text: $$('div.txt').text(),
};
item.language = language;

return item;
})
)
);

const icon = $('link[rel="icon"]').prop('href');
const title = $('title').text();
const image = new URL('template/tenant207/t582/new.jpg', rootUrl).href;

return {
item: items,
title: `军队人才网 - ${$('div.left-word')
.find('a')
.toArray()
.map((a) => $(a).text())
.filter((a) => a !== '首页')
.join(' - ')}`,
title,
description: $('div.time').contents().first().text(),
link: currentUrl,
language: 'zh-cn',
icon,
logo: icon,
item: items,
allowEmpty: true,
image,
author: title.split(/-/).pop()?.trim(),
language,
};
}
};

export const route: Route = {
path: '/81rc/:category{.+}?',
name: '中国人民解放军专业技术人才网',
url: '81rc.81.cn',
maintainers: ['nczitzk'],
handler,
example: '/81/81rc/sy/gzdt_210283',
parameters: { category: '分类,默认为 `sy/gzdt_210283`,即工作动态,可在对应分类页 URL 中找到' },
description: `:::tip
若订阅 [工作动态](https://81rc.81.cn/sy/gzdt_210283),网址为 \`https://81rc.81.cn/sy/gzdt_210283\`。截取 \`https://81rc.81.cn/\` 到末尾的部分 \`sy/gzdt_210283\` 作为参数填入,此时路由为 [\`/81/81rc/sy/gzdt_210283\`](https://rsshub.app/81/81rc/sy/gzdt_210283)。
:::
`,
categories: ['government'],

features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportRadar: true,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['81rc.81.cn/:category'],
target: (params) => {
const category = params.category;

return `/81/81rc/${category ? `/${category}` : ''}`;
},
},
],
};
4 changes: 3 additions & 1 deletion lib/routes/81/namespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ import type { Namespace } from '@/types';

export const namespace: Namespace = {
name: '中国军网',
url: '81rc.81.cn',
url: '81.cn',
categories: ['government'],
description: '',
};
4 changes: 2 additions & 2 deletions lib/routes/pornhub/pornstar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ export const route: Route = {

async function handler(ctx) {
const { language = 'www', username, sort = 'mr' } = ctx.req.param();
const link = `https://${language}.pornhub.com/pornstar/${username}/videos?o=${sort}`;
const link = `https://${language}.pornhub.com/pornstar/${username}?o=${sort}`;
if (!isValidHost(language)) {
throw new InvalidParameterError('Invalid language');
}

const { data: response } = await got(link, { headers });
const $ = load(response);
const items = $('#mostRecentVideosSection .videoBox')
const items = $('#pornstarsVideoSection .videoBox')
.toArray()
.map((e) => parseItems($(e)));

Expand Down
64 changes: 31 additions & 33 deletions lib/routes/swpu/bgw.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Route } from '@/types';
import { DataItem, Route, Data } from '@/types';
import cache from '@/utils/cache';
import { joinUrl } from './utils';
import { parseDate } from '@/utils/parse-date';
Expand Down Expand Up @@ -29,53 +29,51 @@ export const route: Route = {
maintainers: ['CYTMWIA'],
handler,
url: 'swpu.edu.cn/',
description: `| 栏目 | 重要通知公告 | 部门通知公告 | 本周活动 | 学术报告 |
| ---- | ------------ | ------------ | -------- | -------- |
| 代码 | zytzgg | bmtzgg | bzhd | xsbg |`,
description: `| 栏目 | 重要通知公告 | 部门通知公告 | 本周活动 |
| ---- | ------------ | ------------ | -------- |
| 代码 | zytzgg | bmtzgg | bzhd |`,
};

async function handler(ctx) {
const url = `https://www.swpu.edu.cn/bgw2/${ctx.req.param('code')}.htm`;
async function handler(ctx): Promise<Data> {
const url = `https://www.swpu.edu.cn/bgw/${ctx.req.param('code')}.htm`;

const res = await got.get(url);
const $ = load(res.data);

const title = $('.title').text();

// 获取标题、时间及链接
const items = [];
$('.notice > ul > li > a').each((i, elem) => {
items.push({
const items: DataItem[] = $('.notice > ul > li > a')
.toArray()
.map((elem) => ({
title: $(elem.children[0]).text(),
pubDate: timezone(parseDate($(elem.children[1]).text()), +8),
link: joinUrl('https://www.swpu.edu.cn', $(elem).attr('href')), // 实际获得连接 "../info/1312/17891.htm"
});
});
}));

// 请求全文
const out = await Promise.all(
items.map(async (item) => {
const $ = await cache.tryGet(item.link, async () => {
const res = await got.get(item.link);
return load(res.data);
});

if ($('title').text().startsWith('系统提示')) {
item.author = '系统';
item.description = '无权访问';
} else {
item.author = '办公网';
item.description = $('.v_news_content').html();
for (const elem of $('.v_news_content p')) {
if ($(elem).css('text-align') === 'right') {
item.author = $(elem).text();
break;
const out: DataItem[] = await Promise.all(
items.map(
async (item: DataItem) =>
(await cache.tryGet(item.link!, async () => {
const resp = await got.get(item.link);
const $ = load(resp.data);
if ($('title').text().startsWith('系统提示')) {
item.author = '系统';
item.description = '无权访问';
} else {
item.author = '办公网';
item.description = $('.v_news_content').html()!;
for (const elem of $('.v_news_content p')) {
if ($(elem).css('text-align') === 'right') {
item.author = $(elem).text();
break;
}
}
}
}
}

return item;
})
return item;
})) as DataItem
)
);

return {
Expand Down
56 changes: 27 additions & 29 deletions lib/routes/swpu/dean.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Route } from '@/types';
import { DataItem, Route, Data } from '@/types';
import cache from '@/utils/cache';
import { joinUrl } from './utils';
import { parseDate } from '@/utils/parse-date';
Expand Down Expand Up @@ -34,7 +34,7 @@ export const route: Route = {
| 代码 | tzgg | xwbd | sdsy |`,
};

async function handler(ctx) {
async function handler(ctx): Promise<Data> {
const url = `https://www.swpu.edu.cn/dean/${ctx.req.param('code')}.htm`;

const res = await got.get(url);
Expand All @@ -44,39 +44,37 @@ async function handler(ctx) {
title = title.substring(title.indexOf(':') + 1);

// 获取标题、时间及链接
const items = [];
$('.r_list > ul > li').each((i, elem) => {
items.push({
const items: DataItem[] = $('.r_list > ul > li')
.toArray()
.map((elem) => ({
title: $('label:eq(0)', elem).text().trim(),
link: joinUrl('https://www.swpu.edu.cn/dean/', $('a', elem).attr('href')),
});
});
}));

// 请求全文
const out = await Promise.all(
items.map(async (item) => {
const $ = await cache.tryGet(item.link, async () => {
const res = await got.get(item.link);
return load(res.data);
});

if ($('title').text().startsWith('系统提示')) {
item.author = '系统';
item.description = '无权访问';
} else {
item.author = '教务处';
item.description = $('.v_news_content').html();
item.pubDate = timezone(parseDate($('#lbDate').text(), '更新时间:YYYY年MM月DD日'), +8);
for (const elem of $('.v_news_content p')) {
if ($(elem).css('text-align') === 'right') {
item.author = $(elem).text();
break;
items.map(
async (item) =>
(await cache.tryGet(item.link!, async () => {
const resp = await got.get(item.link);
const $ = load(resp.data);
if ($('title').text().startsWith('系统提示')) {
item.author = '系统';
item.description = '无权访问';
} else {
item.author = '教务处';
item.description = $('.v_news_content').html()!;
item.pubDate = timezone(parseDate($('#lbDate').text(), '更新时间:YYYY年MM月DD日'), +8);
for (const elem of $('.v_news_content p')) {
if ($(elem).css('text-align') === 'right') {
item.author = $(elem).text();
break;
}
}
}
}
}

return item;
})
return item;
})) as DataItem
)
);

return {
Expand Down
Loading

0 comments on commit b558d4f

Please sign in to comment.