/ clis / douyin / location.js
location.js
 1  import { cli, Strategy } from '@jackwener/opencli/registry';
 2  import { browserFetch } from './_shared/browser-fetch.js';
 3  cli({
 4      site: 'douyin',
 5      name: 'location',
 6      description: '地理位置 POI 搜索',
 7      domain: 'creator.douyin.com',
 8      strategy: Strategy.COOKIE,
 9      args: [
10          { name: 'query', required: true, positional: true, help: '地名关键词' },
11          { name: 'limit', type: 'int', default: 20 },
12      ],
13      columns: ['poi_id', 'name', 'address', 'city'],
14      func: async (page, kwargs) => {
15          const url = `https://creator.douyin.com/aweme/v1/life/video_api/search/poi/?keyword=${encodeURIComponent(kwargs.query)}&count=${kwargs.limit}&aid=1128`;
16          const res = await browserFetch(page, 'GET', url);
17          return (res.poi_list ?? []).map(p => ({
18              poi_id: p.poi_id,
19              name: p.poi_name,
20              address: p.address,
21              city: p.city_name,
22          }));
23      },
24  });