9b395f5cc3
E2E Headed Chrome / e2e-headed (macos-15) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (ubuntu-latest) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (windows-latest) (push) Has been cancelled
CI / build (macos-latest) (push) Has been cancelled
CI / build (ubuntu-latest) (push) Has been cancelled
CI / build (windows-latest) (push) Has been cancelled
CI / unit-test (push) Has been cancelled
CI / bun-test (push) Has been cancelled
CI / adapter-test (push) Has been cancelled
CI / smoke-test (macos-latest) (push) Has been cancelled
CI / smoke-test (ubuntu-latest) (push) Has been cancelled
Security Audit / audit (push) Has been cancelled
Build Chrome Extension / build (push) Has been cancelled
Trigger Website Rebuild (Docs Updated) / dispatch (push) Has been cancelled
45 lines
1.3 KiB
JavaScript
45 lines
1.3 KiB
JavaScript
import { cli } from '@jackwener/opencli/registry';
|
|
cli({
|
|
site: 'zhihu',
|
|
name: 'hot',
|
|
access: 'read',
|
|
description: '知乎热榜',
|
|
domain: 'www.zhihu.com',
|
|
args: [
|
|
{ name: 'limit', type: 'int', default: 20, help: 'Number of items to return' },
|
|
],
|
|
columns: ['rank', 'title', 'heat', 'answers'],
|
|
pipeline: [
|
|
{ navigate: 'https://www.zhihu.com' },
|
|
{ evaluate: `(async () => {
|
|
const res = await fetch('https://www.zhihu.com/api/v3/feed/topstory/hot-lists/total?limit=50', {
|
|
credentials: 'include'
|
|
});
|
|
const text = await res.text();
|
|
const d = JSON.parse(
|
|
text.replace(/("id"\\s*:\\s*)(\\d{16,})/g, '$1"$2"')
|
|
);
|
|
return (d?.data || []).map((item) => {
|
|
const t = item.target || {};
|
|
const questionId = t.id == null ? '' : String(t.id);
|
|
return {
|
|
title: t.title,
|
|
url: 'https://www.zhihu.com/question/' + questionId,
|
|
answer_count: t.answer_count,
|
|
follower_count: t.follower_count,
|
|
heat: item.detail_text || '',
|
|
};
|
|
});
|
|
})()
|
|
` },
|
|
{ map: {
|
|
rank: '${{ index + 1 }}',
|
|
title: '${{ item.title }}',
|
|
heat: '${{ item.heat }}',
|
|
answers: '${{ item.answer_count }}',
|
|
url: '${{ item.url }}',
|
|
} },
|
|
{ limit: '${{ args.limit }}' },
|
|
],
|
|
});
|