added coccoc and naver autocomplete, added google aliases
This commit is contained in:
1 parent
c5311bc399
commit
761a1e91cd
1 file changed
+57
-1
+57
-1
@@ -23,9 +23,16 @@ class autocomplete{
|
|||||||
"kagi" => "https://kagisuggest.com/api/autosuggest?q={searchTerms}",
|
"kagi" => "https://kagisuggest.com/api/autosuggest?q={searchTerms}",
|
||||||
"startpage" => "https://www.startpage.com/osuggestions?q={searchTerms}",
|
"startpage" => "https://www.startpage.com/osuggestions?q={searchTerms}",
|
||||||
"yahoo" => "https://search.yahoo.com/sugg/gossip/gossip-us-ura/?output=sd1&command={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
|
Sanitize input
|
||||||
*/
|
*/
|
||||||
@@ -196,6 +203,55 @@ class autocomplete{
|
|||||||
);
|
);
|
||||||
break;
|
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:
|
default:
|
||||||
// if it respects the openSearch protocol
|
// if it respects the openSearch protocol
|
||||||
$json = json_decode($this->get($this->scrapers[$scraper], $_GET["s"]), true);
|
$json = json_decode($this->get($this->scrapers[$scraper], $_GET["s"]), true);
|
||||||
|
|||||||
Reference in new issue
Block a user