added coccoc and naver autocomplete, added google aliases

This commit is contained in:
lolcat committed 2026-11-15 19:14:37 -05:00
1 parent c5311bc399
commit 761a1e91cd
1 file changed
+57 -1
+57 -1
View File
@@ -23,9 +23,16 @@ class autocomplete{
"kagi" => "https://kagisuggest.com/api/autosuggest?q={searchTerms}",
"startpage" => "https://www.startpage.com/osuggestions?q={searchTerms}",
"yahoo" => "https://search.yahoo.com/sugg/gossip/gossip-us-ura/?output=sd1&command={searchTerms}",
"purili" => "https://puri.li/api/suggest?q={searchTerms}"
"purili" => "https://puri.li/api/suggest?q={searchTerms}",
"coccoc" => "https://coccoc.com/composer/autocomplete?q={searchTerms}",
"naver" => "https://ac.search.naver.com/nx/ac?q={searchTerms}&st=100"
];
// add duplicates
$this->scrapers["google_api"] = &$this->scrapers["google"];
$this->scrapers["google_cse"] = &$this->scrapers["google"];
$this->scrapers["yahoo_japan"] = &$this->scrapers["yahoo"];
/*
Sanitize input
*/
@@ -196,6 +203,55 @@ class autocomplete{
);
break;
case "naver":
$json = $this->get($this->scrapers[$scraper], $_GET["s"]);
$json = json_decode($json, true);
if(
$json === null ||
!isset($json["items"][0][0])
){
$this->doempty();
}
$payload = [];
foreach($json["items"][0] as $term){
$payload[] = $term[0];
}
echo json_encode(
[
$_GET["s"],
$payload
],
JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_INVALID_UTF8_IGNORE
);
break;
case "coccoc":
$json = $this->get($this->scrapers[$scraper], $_GET["s"]);
$json = json_decode($json, true);
if(
$json === null ||
!isset($json["suggestions"])
){
$this->doempty();
}
echo json_encode(
[
$_GET["s"],
$json["suggestions"]
],
JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_INVALID_UTF8_IGNORE
);
break;
default:
// if it respects the openSearch protocol
$json = json_decode($this->get($this->scrapers[$scraper], $_GET["s"]), true);