Skip to content

Commit

Permalink
Merge pull request #1368 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 Apr 26, 2024
2 parents 93f4850 + 7e87a48 commit 2667596
Show file tree
Hide file tree
Showing 13 changed files with 507 additions and 215 deletions.
79 changes: 0 additions & 79 deletions lib/routes-deprecated/kpmg/insights.js

This file was deleted.

80 changes: 80 additions & 0 deletions lib/routes/gov/zj/search.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import { Route } from '@/types';
import { parseDate } from '@/utils/parse-date';
import got from '@/utils/got';
import { load } from 'cheerio';
import dayjs from 'dayjs';

export const route: Route = {
path: '/zj/search/:websiteid?/:word/:cateid?',
categories: ['government'],
example: '/gov/zj/search',
parameters: {
websiteid: '搜索范围-全省、各市各区、详细信息点击源网站https://www.zj.gov.cn/请求中寻找',
word: '搜索关键词-默认:人才',
cateid: '信息分类-默认:658(全部)',
sortType: '排序类型-默认:2(按时间)',
},
radar: [
{
source: ['search.zj.gov.cn/jsearchfront/search.do'],
target: '/zj/search/:websiteid?/:word/:cateid?',
},
],
name: '浙江省人民政府-全省政府网站统一搜索',
url: 'search.zj.gov.cn/jsearchfront/search.do',
maintainers: ['HaoyuLee'],
description: `
| 行政区域 | websiteid |
| ------------ | -- |
| 宁波市本级 | 330201000000000 |
| 搜索关键词 | word |
| 信息分类 | cateid |
| 排序类型 | sortType |
| ------------ | -- |
| 按相关度 | 1 |
| 按时间 | 2 |
`,
async handler(ctx) {
const { websiteid = '330201000000000', word = '人才', cateid = 658, sortType = 2 } = ctx.req.param();
const {
data: { result: list },
} = await got.post('https://search.zj.gov.cn/jsearchfront/interfaces/cateSearch.do', {
form: {
websiteid,
pg: '30',
p: '1',
cateid,
word,
checkError: 1,
isContains: 0,
q: word,
begin: dayjs().subtract(1, 'week').format('YYYYMMDD'),
end: dayjs().format('YYYYMMDD'),
timetype: 2,
pos: 'title,content,keyword',
sortType,
},
});
const items =
list?.map((item: string) => {
const $ = load(item);
const title = $('.titleWrapper>a');
const footer = $('.sourceTime>span');
return {
title: title.text().trim() || '',
link: title.attr('href') || '',
pubDate: parseDate(footer.eq(1).text().trim().replace('时间:', '')) || '',
author: footer.eq(0).text().trim().replace('来源:', '') || '',
description: $('.newsDescribe>a').text() || '',
};
}) || [];
return {
title: '浙江省人民政府-全省政府网站统一搜索',
link: 'https://search.zj.gov.cn/jsearchfront/search.do',
item: items,
};
},
};
125 changes: 125 additions & 0 deletions lib/routes/iehou/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
import { Route } from '@/types';

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 handler = async (ctx) => {
const { category = '' } = ctx.req.param();
const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 100;

const rootUrl = 'https://iehou.com';
const currentUrl = new URL(category ? `page-${category}.htm` : '', rootUrl).href;

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

const $ = load(response);

const language = $('html').prop('lang');

let items = $('li.list-group-item div.subject h2')
.slice(0, limit)
.toArray()
.map((item) => {
item = $(item);

const title = item.text();

return {
title,
pubDate: timezone(parseDate(item.parent().find('span').text(), 'MM-DD HH:mm', 'YYYY-MM-DD HH:mm'), +8),
link: item.find('a').prop('href'),
category: item
.nextAll('a')
.toArray()
.map((c) => $(c).text()),
language,
};
});

items = await Promise.all(
items.map((item) =>
cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);

const $$ = load(detailResponse);

const title = $$('h1.title').text();
const description = $$('div.thread-content').html();
const image = $$('div.thread-content img').first().prop('src');

item.title = title;
item.description = description;
item.pubDate = timezone(parseDate($$('i.icon-clock-o').parent().contents().last().text().trim(), 'MM-DD HH:mm', 'YYYY-MM-DD HH:mm'), +8);
item.author = $$('img.avatar-1').parent().contents().last().text().trim();
item.content = {
html: description,
text: $$('div.thread-content').text(),
};
item.image = image;
item.banner = image;
item.language = language;

return item;
})
)
);

return {
title: $('title').text(),
description: $('meta[name="description"]').prop('content'),
link: currentUrl,
item: items,
allowEmpty: true,
author: $('h1').text(),
language,
};
};

export const route: Route = {
path: '/:category?',
name: '线报',
url: 'iehou.com',
maintainers: ['nczitzk'],
handler,
example: '/iehou',
parameters: { category: '分类,默认为空,即最新线报,可在对应分类页 URL 中找到' },
description: `:::tip
若订阅 [24小时热门线报](https://iehou.com/page-dayhot.htm),网址为 \`https://iehou.com/page-dayhot.htm\`。截取 \`https://iehou.com/page-\` 到末尾 \`.htm\` 的部分 \`dayhot\` 作为参数填入,此时路由为 [\`/iehou/dayhot\`](https://rsshub.app/iehou/dayhot)。
:::
| [最新线报](https://iehou.com/) | [24 小时热门](https://iehou.com/page-dayhot.htm) | [一周热门](https://iehou.com/page-weekhot.htm) |
| ------------------------------ | ------------------------------------------------ | ---------------------------------------------- |
| [](https://rsshub.app/iehou) | [dayhot](https://rsshub.app/iehou/dayhot) | [weekhot](https://rsshub.app/iehou/weekhot) |
`,
categories: ['new-media'],

features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportRadar: true,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
title: '最新线报',
source: ['iehou.com'],
target: '/',
},
{
title: '24小时热门',
source: ['iehou.com/page-dayhot.htm'],
target: '/dayhot',
},
{
title: '一周热门',
source: ['iehou.com/page-weekhot.htm'],
target: '/weekhot',
},
],
};
8 changes: 8 additions & 0 deletions lib/routes/iehou/namespace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { Namespace } from '@/types';

export const namespace: Namespace = {
name: '网猴线报',
url: 'iehou.com',
categories: ['new-media'],
description: '',
};
Loading

0 comments on commit 2667596

Please sign in to comment.