-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.js
88 lines (75 loc) · 2.38 KB
/
index.js
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
var axios = require("axios");
var cheerio = require("cheerio");
var urls = {
google: "https://suggestqueries.google.com/complete/search?output=toolbar&hl=en&q=",
ddg: "https://duckduckgo.com/ac/?kl=wt-wt&q=",
bing: "https://www.bingapis.com/api/v7/suggestions?appid=6D0A9B8C5100E9ECC7E11A104ADD76C10219804B&q=",
qwant: "https://api.qwant.com/api/suggest/?client=opensearch&q=",
yahoo: "https://api.search.yahoo.com/sugg/gossip/gossip-in-ura?output=sd1&command=",
startpage: "https://www.startpage.com/do/suggest?query=",
dogpile: "https://www.dogpile.com/suggestions?q=",
swisscows: "https://swisscows.com/api/suggestion/suggest?query=",
ask: "https://amg-ss.ask.com/query?q=",
brave: "https://search.brave.com/api/suggest?q=",
}
module.exports = class Suggest {
constructor() {}
static async google(q) {
var xmlop = await axios(urls.google + q);
var $ = cheerio.load(xmlop.data);
return $("suggestion").toArray().map(x=>x.attribs.data);
}
static async ddg(q) {
var op = await axios(urls.ddg + q);
return op.data.map(x=>x.phrase);
}
static async bing(q) {
var op = await axios(urls.bing + q);
return op.data.suggestionGroups[0].searchSuggestions.map(x=>x.displayText);
}
static async qwant(q) {
var op = await axios(urls.qwant + q);
return [].concat.apply([], op.data);
}
static async yahoo(q) {
var op = await axios(urls.yahoo + q);
return op.data.r.map(x=>x.k);
}
static async startpage(q) {
var op = await axios(urls.startpage + q);
op = op.data.split("\n");
op.pop();
return op;
}
static async dogpile(q) {
var op = await axios(urls.dogpile + q);
return op.data.suggestions.map(x=>x.text);
}
static async swisscows(q) {
var op = await axios(urls.swisscows + q);
return op.data;
}
static async ask(q) {
var op = await axios(urls.ask + q);
return op.data[1];
}
static async brave(q) {
var op = await axios(urls.brave + q);
return op.data[1];
}
static async all(q) {
var all = [
...await Suggest.google(q),
...await Suggest.ddg(q),
...await Suggest.bing(q),
...await Suggest.qwant(q),
...await Suggest.yahoo(q),
...await Suggest.startpage(q),
...await Suggest.dogpile(q),
...await Suggest.swisscows(q),
...await Suggest.ask(q),
...await Suggest.brave(q)
];
return [...new Set(all)];
}
}