Skip to content

feat(route): add new routes 52pojie ghxi sohumobile #18941

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions lib/routes/52pojie/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { Route } from '@/types';
import ofetch from '@/utils/ofetch';
import { load } from 'cheerio';
import iconv from 'iconv-lite';

export const route: Route = {
path: '/jinpin',
categories: ['bbs'],
example: '/52pojie/jinpin',
parameters: {},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['www.52pojie.cn'],
},
],
name: '52pojie精品软件区最新发贴',
maintainers: ['asqwe1'],
handler: async () => {
const response = await ofetch(`https://www.52pojie.cn/forum.php?mod=forumdisplay&fid=16&filter=author&orderby=dateline`, {
responseType: 'arrayBuffer', // 获取原始二进制数据
});
const decodedHtml = iconv.decode(Buffer.from(response), 'gbk'); // 手动解码 GBK
const $ = load(decodedHtml); // 加载解码后的 HTML
const items = $('tbody[id^="normalthread"] > tr > th')
// 使用“toArray()”方法将选择的所有 DOM 元素以数组的形式返回。
.toArray()
// 使用“map()”方法遍历数组,并从每个元素中解析需要的数据。
.map((item) => {
item = $(item);
const a = item.find('a.s.xst').first();
return {
title: a.text(),
link: `https://www.52pojie.cn/${a.attr('href')}`,
};
Comment on lines +39 to +42
Copy link
Collaborator

Choose a reason for hiding this comment

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

This site provides its RSS feed at https://www.52pojie.cn/forum.php?mod=rss&fid=16 which provides more information than this feed.

});
// 在此处编写路由处理函数
return {
// 源标题
title: `52pojie精品软件区最新发贴`,
// 源链接
link: `https://www.52pojie.cn/forum.php?mod=forumdisplay&fid=16&filter=author&orderby=dateline`,
// 源文章
item: items,
};
},
};
10 changes: 10 additions & 0 deletions lib/routes/52pojie/namespace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { Namespace } from '@/types';

export const namespace: Namespace = {
name: '52pojie',
url: 'm.sohu.com',
description: '52pojie 精品软件区最新发贴',
zh: {
name: '吾爱破解网',
},
};
52 changes: 52 additions & 0 deletions lib/routes/ghxi/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { Route } from '@/types';
import ofetch from '@/utils/ofetch';
import { load } from 'cheerio';

export const route: Route = {
path: '/homepage',
categories: ['other'],
example: '/ghxi/homepage',
parameters: {},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['www.ghxi.com'],
},
],
name: '果核剥壳网-首页新贴',
maintainers: ['asqwe1'],
handler: async () => {
const response = await ofetch(`https://www.ghxi.com/`);
const $ = load(response);
const items = $('#modules-4 > div > div.tab-wrap.active > ul > li > div.item-content')
// 使用“toArray()”方法将选择的所有 DOM 元素以数组的形式返回。
.toArray()
// 使用“map()”方法遍历数组,并从每个元素中解析需要的数据。
.map((item) => {
item = $(item);
const a = item.find('a').first();
const p = item.find('p').first();
return {
title: a.text(),
link: String(a.attr('href')),
content: p.text(),
};
Comment on lines +36 to +40
Copy link
Collaborator

Choose a reason for hiding this comment

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

RSSHub/lib/types.ts

Lines 48 to 51 in b98b497

content?: {
html: string;
text: string;
};

  • content does not accept a plain string.

This site provides its full article RSS feed at https://www.ghxi.com/feed which provides way more information than this feed.

});
// 在此处编写路由处理函数
return {
// 源标题
title: `果核剥壳网-首页新贴`,
// 源链接
link: `https://www.ghxi.com/`,
// 源文章
item: items,
};
},
};
7 changes: 7 additions & 0 deletions lib/routes/ghxi/namespace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { Namespace } from '@/types';

export const namespace: Namespace = {
name: '果核剥壳网-ghxi.com',
url: 'www.ghxi.com',
description: '果核剥壳新发帖子',
};
51 changes: 51 additions & 0 deletions lib/routes/sohumobile/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { Route } from '@/types';
import ofetch from '@/utils/ofetch';
import { load } from 'cheerio';

export const route: Route = {
path: '/limit',
categories: ['traditional-media'],
Copy link
Collaborator

Choose a reason for hiding this comment

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

Traditional media means newspapers, magazines, radio, and television broadcast and I don't think this site has any of these.

example: '/sohumobile/limit',
parameters: {},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: true,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['m.sohu.com/limit'],
target: '/limit',
},
],
name: '手机搜狐网-新闻',
maintainers: ['asqwe1'],
handler: async () => {
const response = await ofetch(`https://m.sohu.com/limit`);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
const response = await ofetch(`https://m.sohu.com/limit`);
const response = await ofetch('https://m.sohu.com/limit');

Only use template literals when necessary.

const $ = load(response);
const items = $('.content-left section > div.f')
// 使用“toArray()”方法将选择的所有 DOM 元素以数组的形式返回。
.toArray()
// 使用“map()”方法遍历数组,并从每个元素中解析需要的数据。
.map((item) => {
item = $(item);
const a = item.find('a').first();
return {
title: a.text(),
link: String(a.attr('href')),
};
});
Comment on lines +29 to +40
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use the embedded JSON window.WapHomeRenderData instead.

// 在此处编写路由处理函数
return {
// 源标题
title: `手机搜狐新闻`,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
title: `手机搜狐新闻`,
title: '手机搜狐新闻',

// 源链接
link: `https://m.sohu.com/limit`,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
link: `https://m.sohu.com/limit`,
link: 'https://m.sohu.com/limit',

// 源文章
item: items,
};
},
};
7 changes: 7 additions & 0 deletions lib/routes/sohumobile/namespace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { Namespace } from '@/types';
Copy link
Collaborator

Choose a reason for hiding this comment

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

The site does not have sohumobile.com in its second level domain. Do not create a namespace that does not follow its second level domain.


export const namespace: Namespace = {
name: '手机搜狐网',
url: 'm.sohu.com',
description: '手机搜狐网的新闻抓取-RSS',
};