topics.js
1 import { cli, Strategy } from '@jackwener/opencli/registry'; 2 3 cli({ 4 site: 'nowcoder', 5 name: 'topics', 6 description: 'Hot discussion topics', 7 domain: 'www.nowcoder.com', 8 strategy: Strategy.PUBLIC, 9 browser: false, 10 args: [ 11 { name: 'limit', type: 'int', default: 10, help: 'Number of items' }, 12 ], 13 columns: ['rank', 'topic', 'views', 'posts', 'heat', 'id'], 14 pipeline: [ 15 { fetch: { url: 'https://gw-c.nowcoder.com/api/sparta/subject/hot-subject' } }, 16 { select: 'data.result' }, 17 { map: { 18 rank: '${{ index + 1 }}', 19 topic: '${{ item.content }}', 20 views: '${{ item.viewCount }}', 21 posts: '${{ item.momentCount }}', 22 heat: '${{ item.hotValue }}', 23 id: '${{ item.uuid || item.id || "" }}', 24 } }, 25 { limit: '${{ args.limit }}' }, 26 ], 27 });