chore: clean up duplicate adapters
- Remove xiaohongshu/search.yaml (keep .ts with XHR interception) - Remove zhihu/search.ts (keep .yaml, self-contained) - Clean ~/.opencli/clis/ generated candidates (5 dirs) 24 commands across 8 sites, no duplicates
This commit is contained in:
1 parent
0988fcb334
commit
9124dcc018
2 files changed
-101
No files matched your search
@@ -1,36 +0,0 @@
|
||||
site: xiaohongshu
|
||||
name: search
|
||||
description: "小红书搜索 (via Pinia Store Action)"
|
||||
domain: www.xiaohongshu.com
|
||||
strategy: intercept
|
||||
browser: true
|
||||
|
||||
args:
|
||||
keyword:
|
||||
type: str
|
||||
required: true
|
||||
description: Search keyword
|
||||
limit:
|
||||
type: int
|
||||
default: 20
|
||||
description: Number of items to return
|
||||
|
||||
columns: [title, author, likes, type, url]
|
||||
|
||||
pipeline:
|
||||
- navigate: https://www.xiaohongshu.com/search_result?keyword=${{ args.keyword }}&source=web_search_result_notes
|
||||
- wait: 3
|
||||
- tap:
|
||||
store: search
|
||||
action: fetchResult
|
||||
capture: search/notes
|
||||
select: data.items
|
||||
timeout: 8
|
||||
- map:
|
||||
id: ${{ item.id }}
|
||||
title: ${{ item.note_card.display_title }}
|
||||
type: ${{ item.note_card.type }}
|
||||
author: ${{ item.note_card.user.nickname }}
|
||||
likes: ${{ item.note_card.interact_info.liked_count }}
|
||||
url: https://www.xiaohongshu.com/explore/${{ item.id }}
|
||||
- limit: ${{ args.limit | default(20) }}
|
||||
@@ -1,65 +0,0 @@
|
||||
import { cli, Strategy } from '../../registry.js';
|
||||
import { fetchJson } from '../../bilibili.js';
|
||||
|
||||
cli({
|
||||
site: 'zhihu',
|
||||
name: 'search',
|
||||
description: '搜索知乎问题和回答',
|
||||
domain: 'www.zhihu.com',
|
||||
strategy: Strategy.COOKIE,
|
||||
args: [
|
||||
{ name: 'keyword', required: true, help: 'Search keyword' },
|
||||
{ name: 'type', default: 'general', help: 'general, article, video' },
|
||||
{ name: 'limit', type: 'int', default: 20, help: 'Number of results' },
|
||||
],
|
||||
columns: ['rank', 'title', 'author', 'type', 'url'],
|
||||
func: async (page, kwargs) => {
|
||||
const { keyword, type = 'general', limit = 20 } = kwargs;
|
||||
|
||||
// Navigate to zhihu to ensure cookie context
|
||||
await page.goto('https://www.zhihu.com');
|
||||
|
||||
const qs = new URLSearchParams({ q: keyword, type, limit: String(limit) });
|
||||
const payload = await fetchJson(page, `https://www.zhihu.com/api/v4/search_v3?${qs}`);
|
||||
|
||||
const data: any[] = payload?.data ?? [];
|
||||
const rows: any[] = [];
|
||||
|
||||
for (let i = 0; i < Math.min(data.length, Number(limit)); i++) {
|
||||
const item = data[i];
|
||||
const obj = item.object ?? item;
|
||||
const itemType = item.type ?? obj.type ?? 'unknown';
|
||||
|
||||
let title = '';
|
||||
let author = '';
|
||||
let url = '';
|
||||
|
||||
if (itemType === 'search_result') {
|
||||
const highlight = obj.highlight ?? {};
|
||||
title = (highlight.title ?? obj.title ?? '').replace(/<[^>]+>/g, '');
|
||||
author = obj.author?.name ?? '';
|
||||
url = obj.url ?? '';
|
||||
} else if (obj.question) {
|
||||
title = (obj.question.title ?? obj.title ?? '').replace(/<[^>]+>/g, '');
|
||||
author = obj.author?.name ?? '';
|
||||
url = obj.question.url ? `https://www.zhihu.com/question/${obj.question.id}` : '';
|
||||
} else {
|
||||
title = (obj.title ?? obj.name ?? '').replace(/<[^>]+>/g, '');
|
||||
author = obj.author?.name ?? '';
|
||||
url = obj.url ?? '';
|
||||
}
|
||||
|
||||
if (!title) continue;
|
||||
|
||||
rows.push({
|
||||
rank: rows.length + 1,
|
||||
title: title.slice(0, 60),
|
||||
author,
|
||||
type: itemType.replace('search_result', 'result'),
|
||||
url,
|
||||
});
|
||||
}
|
||||
|
||||
return rows;
|
||||
},
|
||||
});
|
||||
Reference in new issue
Block a user