-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.ts
54 lines (48 loc) · 1.33 KB
/
search.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
42
43
44
45
46
47
48
49
50
51
52
53
import { duckIt } from 'node-duckduckgo'
import { URL } from 'url';
export interface Result {
Abstract: string;
AbstractText: string;
AbstractSource: string;
AbstractURL: string;
Image: string;
Heading: string;
Answer: string;
AnswerType: "calc" | "color" | "digest" | "info" | "ip" | "iploc" | "phone" | "pw" | "rand" | "regexp" | "unicode" | "upc" | "zip";
Definition: string;
DefinitionSource: string;
DefinitionURL: string;
RelatedTopics: [
{
Result: string;
FirstURL: string;
Icon: {
URL: string;
Height: number;
Width: number;
}
Text: string;
}
]
Results: [
{
Result: string;
FirstURL: string;
Icon: {
URL: string;
Height: number;
Width: number;
}
Text: string;
}
]
// A (article), D (disambiguation), C (category), N (name), E (exclusive), or nothing
Type: "A" | "D" | "C" | "N" | "E" | "";
Redirect: string;
}
export async function duckSearch(query: string) {
console.log(query)
const result = await duckIt(query, {noHtml: true, noRedirect: true});
return <Result> result.data;
console.log(result.data);
}