Skip to content
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
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
50 changes: 11 additions & 39 deletions docker-compose.yml
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do not modify the docker compose file.

Original file line number Diff line number Diff line change
@@ -1,50 +1,22 @@
version: '3.8'
services:
rsshub:
# two ways to enable Playwright:
# * comment out marked lines, then use this image instead: diygod/rsshub:chromium-bundled
# * (consumes more disk space and memory) leave everything unchanged
image: diygod/rsshub # or ghcr.io/diygod/rsshub
image: franksun123/rsshub:latest
container_name: rsshubfrank
restart: always
ports:
- '1200:1200'
network_mode: host
environment:
NODE_ENV: production
CACHE_TYPE: redis
REDIS_URL: 'redis://redis:6379/'
PLAYWRIGHT_WS_ENDPOINT: 'ws://browserless:3000' # marked
healthcheck:
test: ['CMD', 'curl', '-f', 'http://localhost:1200/healthz']
interval: 30s
timeout: 10s
retries: 3
- NODE_ENV=production
- CACHE_TYPE=redis
- REDIS_URL=redis://127.0.0.1:6379/0
- FLARESOLVERR_URL=http://127.0.0.1:8191/v1
depends_on:
- redis
- browserless # marked

browserless: # marked
image: browserless/chrome # marked
restart: always # marked
ulimits: # marked
core: # marked
hard: 0 # marked
soft: 0 # marked
healthcheck: # marked
test: ['CMD', 'curl', '-f', 'http://localhost:3000/pressure'] # marked
interval: 30s # marked
timeout: 10s # marked
retries: 3 # marked

redis:
image: redis:alpine
container_name: rsshub-redis
restart: always
network_mode: host
volumes:
- redis-data:/data
healthcheck:
test: ['CMD', 'redis-cli', 'ping']
interval: 30s
timeout: 10s
retries: 5
start_period: 5s

volumes:
redis-data:
- ./redis-data:/data
89 changes: 89 additions & 0 deletions lib/routes/gxnas/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import { load } from 'cheerio';

Check failure

Code scanning / oxlint

simple-import-sort(imports) Error

Run autofix to sort these imports!
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
import { getPlaywrightPage } from '@/utils/playwright';
import { parseDate } from '@/utils/parse-date';
import type { DataItem, Route } from '@/types';

export const route: Route = {
path: '/',
categories: ['blog'],
example: '/gxnas',
radar: [
{
source: ['wp.gxnas.com/'],
},
],
url: 'wp.gxnas.com/',
name: '最新文章',
maintainers: ['Franklittleboy'],
handler,
description: `::: warning
该网站受 Cloudflare 保护,自建实例需要 Chromium 支持(默认已包含)。
:::`,
features: {
requireConfig: false,
requirePuppeteer: true,
antiCrawler: true,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
};

async function handler() {
const rootUrl = 'https://wp.gxnas.com';

const { page, destroy } = await getPlaywrightPage('about:blank');

// Only load document resources to speed up page load
await page.setRequestInterception(true);
page.on('request', (request) => {
request.resourceType() === 'document' ? request.continue() : request.abort();
});

await page.goto(rootUrl, { waitUntil: 'domcontentloaded' });

const html = await page.content();
await page.close();
await destroy();

const $ = load(html);

const items = $('.article-panel')
.toArray()
.map((el) => {
const $el = $(el);
const titleEl = $el.find('.header .title a');
const title = titleEl.text().trim();
const link = titleEl.attr('href');
const categoryEl = $el.find('.header .label');
const category = categoryEl.text().trim();
const contentEl = $el.find('.content');
const description = contentEl.html() || '';
const thumbEl = $el.find('.a-thumb img');
const image = thumbEl.attr('src');

// Date format: 2023年11月17日
const dateText = $el.find('.a-meta span').first().text().trim();
let pubDate: Date | undefined;
const m = dateText.match(/(\d{4})年(\d{1,2})月(\d{1,2})日/);
if (m) {
pubDate = new Date(Number.parseInt(m[1]), Number.parseInt(m[2]) - 1, Number.parseInt(m[3]));
}

return {
title,
link,
description: image ? `<img src="${image}"><br>${description}` : description,
category,
pubDate: pubDate && parseDate(pubDate),
} as DataItem;
})
.filter((item) => item.title && item.link);

return {
title: 'GXNAS博客',
link: rootUrl,
item: items,
description: 'GXNAS博客 - NAS博客|NAS社区|NAS交流|NAS技术|群晖教程|软路由',
};
}
8 changes: 8 additions & 0 deletions lib/routes/gxnas/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: 'GXNAS博客',
url: 'wp.gxnas.com',
description: 'GXNAS博客 - NAS技术交流',
lang: 'zh-CN',
};