/
app.ts
41 lines (34 loc) · 1.09 KB
/
app.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { BaiduIndex } from '../dist/lib/baidu-index';
async function example() {
try {
const baiduIndex = new BaiduIndex(
process.env.BAIDU_TOKEN!,
process.env.BAIDU_NAME!
);
const { taskId } = await baiduIndex.createTask({
datasource: 'search',
dateRange: {
start: '2024-04-01',
end: '2024-04-01',
},
device: ['all'],
region: {
province: [],
city: [],
isAll: true,
},
keyword: ['小米'],
});
const result = await baiduIndex.getResult(taskId);
console.log(result);
const keywordsMap1 = await baiduIndex.checkKeywords(['小米', 'symcxw']);
console.log(keywordsMap1);
const { accessToken } = await baiduIndex.refreshAccessToken();
console.log(accessToken);
const keywordsMap2 = await baiduIndex.checkKeywords(['小米', 'symcxw']);
console.log(keywordsMap2);
} catch (e) {
console.error(e);
}
}
example();