mirror of
https://github.com/gnh1201/welsonjs.git
synced 2024-11-26 07:21:43 +00:00
Update the search engines
This commit is contained in:
parent
d3743e206c
commit
8bb0f68049
25
lib/http.js
25
lib/http.js
|
@ -1,6 +1,6 @@
|
|||
// http.js
|
||||
// HTTP REST Client for WelsonJS framework
|
||||
// Namhyeon Go (Catswords Research) <abuse@catswords.net>
|
||||
// Namhyeon Go (Catswords Research) <abuse@catswords.net>
|
||||
// https://github.com/gnh1201/welsonjs
|
||||
var SYS = require("lib/system");
|
||||
var FILE = require("lib/file");
|
||||
|
@ -8,6 +8,7 @@ var SHELL = require("lib/shell");
|
|||
var RAND = require("lib/rand");
|
||||
var BASE64 = require("lib/base64");
|
||||
var PipeIPC = require("lib/pipe-ipc");
|
||||
var JsonRpc2 = require("lib/jsonrpc2");
|
||||
|
||||
var OS_NAME = SYS.getOS();
|
||||
var OS_ARCH = SYS.getArch();
|
||||
|
@ -38,19 +39,19 @@ var AVAILABLE_PROXIES = [
|
|||
{
|
||||
"type": "serp",
|
||||
"provider": "librey",
|
||||
"url": "https://serp.catswords.net/api.php?q={q}&p=1&t=0",
|
||||
"url": "https://farside.link/librex/api.php?q={q}&p=1&t=0",
|
||||
"documentation": "https://github.com/Ahwxorg/LibreY"
|
||||
},
|
||||
{
|
||||
"type": "serp",
|
||||
"provider": "invidious",
|
||||
"url": "https://invidious.example.org/api/v1/search?q={q}",
|
||||
"url": "https://farside.link/invidious/api/v1/search?q={q}",
|
||||
"documentation": "https://docs.invidious.io/"
|
||||
},
|
||||
{
|
||||
"type": "stateless-jsonrpc2",
|
||||
"provider": "gnh1201/caterpillar",
|
||||
"url": "http://localhost:5555",
|
||||
"url": "http://localhost:8080",
|
||||
"documentation": "https://github.com/gnh1201/caterpillar"
|
||||
},
|
||||
{
|
||||
|
@ -511,20 +512,22 @@ var HTTPObject = function(engine) {
|
|||
|
||||
this.parseSerpUrl = function(url) {
|
||||
var getEngine = function(url) {
|
||||
var match = url.match(/(?:https?:\/\/)?(?:www\.)?(google|youtube|bing|baidu|amazon|naver|daum)\.\w+/), result;
|
||||
var match = url.match(/(?:https?:\/\/)?(?:www\.)?(google|youtube|bing|baidu|amazon|duckduckgo|naver|daum|aliexpress|temu|coupang)|\.\w+/), engine;
|
||||
if (match) {
|
||||
result = match[1];
|
||||
if (result == "naver" || result == "daum") {
|
||||
result = "google";
|
||||
engine = match[1];
|
||||
if (["naver", "daum"].indexOf(engine) > -1) {
|
||||
engine = "google";
|
||||
} else if (["aliexpress", "temu", "coupang"].indexOf(engine) > -1) {
|
||||
engine = "google_shopping";
|
||||
}
|
||||
} else {
|
||||
result = "google";
|
||||
engine = "google";
|
||||
}
|
||||
return result;
|
||||
return engine;
|
||||
};
|
||||
|
||||
var getKeyword = function(url) {
|
||||
var regex = /[?&](q|wd|query|search_query|k)=([^&]*)/g;
|
||||
var regex = /[?&](q|wd|query|search_query|k|SearchText|search_key)=([^&]*)/g;
|
||||
var match, keywords = [];
|
||||
while ((match = regex.exec(url)) !== null) {
|
||||
keywords.push(match[2]);
|
||||
|
|
Loading…
Reference in New Issue
Block a user