yep scraper fix, removed image and news

This commit is contained in:
2026-04-26 05:08:15 -04:00
parent b1f5974e40
commit a54f212550
3 changed files with 200 additions and 503 deletions

View File

@@ -673,7 +673,6 @@ class frontend{
"yahoo_japan" => "Yahoo! JAPAN", "yahoo_japan" => "Yahoo! JAPAN",
"startpage" => "Startpage", "startpage" => "Startpage",
"qwant" => "Qwant", "qwant" => "Qwant",
"yep" => "Yep",
"baidu" => "Baidu", "baidu" => "Baidu",
"solofield" => "Solofield", "solofield" => "Solofield",
"pinterest" => "Pinterest", "pinterest" => "Pinterest",
@@ -724,7 +723,6 @@ class frontend{
"yahoo_japan" => "Yahoo! JAPAN", "yahoo_japan" => "Yahoo! JAPAN",
"startpage" => "Startpage", "startpage" => "Startpage",
"qwant" => "Qwant", "qwant" => "Qwant",
"yep" => "Yep",
"mojeek" => "Mojeek", "mojeek" => "Mojeek",
"baidu" => "Baidu" "baidu" => "Baidu"
] ]

View File

@@ -14,227 +14,202 @@ class yep{
public function getfilters($page){ public function getfilters($page){
return [ return [
"country" => [ "lang" => [
"display" => "Country", "display" => "Language",
"option" => [ "option" => [
"all" => "All regions", "any" => "Any language",
"af" => "Afghanistan", "aa" => "Afar",
"al" => "Albania", "ab" => "Abkhazian",
"dz" => "Algeria", "ae" => "Avestan",
"as" => "American Samoa", "af" => "Afrikaans",
"ad" => "Andorra", "ak" => "Akan",
"ao" => "Angola", "am" => "Amharic",
"ai" => "Anguilla", "an" => "Aragonese",
"ag" => "Antigua and Barbuda", "ar" => "Arabic",
"ar" => "Argentina", "as" => "Assamese",
"am" => "Armenia", "av" => "Avaric",
"aw" => "Aruba", "ay" => "Aymara",
"au" => "Australia", "az" => "Azerbaijani",
"at" => "Austria", "ba" => "Bashkir",
"az" => "Azerbaijan", "be" => "Belarusian",
"bs" => "Bahamas", "bg" => "Bulgarian",
"bh" => "Bahrain", "bh" => "Bihari",
"bd" => "Bangladesh", "bi" => "Bislama",
"bb" => "Barbados", "bm" => "Bambara",
"by" => "Belarus", "bn" => "Bengali",
"be" => "Belgium", "bo" => "Tibetan",
"bz" => "Belize", "br" => "Breton",
"bj" => "Benin", "bs" => "Bosnian",
"bt" => "Bhutan", "ca" => "Catalan",
"bo" => "Bolivia", "ce" => "Chechen",
"ba" => "Bosnia and Herzegovina", "ch" => "Chamorro",
"bw" => "Botswana", "co" => "Corsican",
"br" => "Brazil", "cr" => "Cree",
"bn" => "Brunei Darussalam", "cs" => "Czech",
"bg" => "Bulgaria", "cu" => "Church Slavic",
"bf" => "Burkina Faso", "cv" => "Chuvash",
"bi" => "Burundi", "cy" => "Welsh",
"cv" => "Cabo Verde", "da" => "Danish",
"kh" => "Cambodia", "de" => "German",
"cm" => "Cameroon", "dv" => "Divehi",
"ca" => "Canada", "dz" => "Dzongkha",
"ky" => "Cayman Islands", "ee" => "Ewe",
"cf" => "Central African Republic", "el" => "Greek",
"td" => "Chad", "en" => "English",
"cl" => "Chile", "eo" => "Esperanto",
"cn" => "China", "es" => "Spanish",
"co" => "Colombia", "et" => "Estonian",
"cg" => "Congo", "eu" => "Basque",
"cd" => "Congo, Democratic Republic", "fa" => "Persian",
"ck" => "Cook Islands", "ff" => "Fulah",
"cr" => "Costa Rica", "fi" => "Finnish",
"hr" => "Croatia", "fj" => "Fijian",
"cu" => "Cuba", "fo" => "Faroese",
"cy" => "Cyprus", "fr" => "French",
"cz" => "Czechia", "fy" => "Western Frisian",
"ci" => "Côte d'Ivoire", "ga" => "Irish",
"dk" => "Denmark", "gd" => "Scottish Gaelic",
"dj" => "Djibouti", "gl" => "Galician",
"dm" => "Dominica", "gn" => "Guarani",
"do" => "Dominican Republic", "gu" => "Gujarati",
"ec" => "Ecuador", "gv" => "Manx",
"eg" => "Egypt", "ha" => "Hausa",
"sv" => "El Salvador", "he" => "Hebrew",
"gq" => "Equatorial Guinea", "hi" => "Hindi",
"ee" => "Estonia", "ho" => "Hiri Motu",
"et" => "Ethiopia", "hr" => "Croatian",
"fo" => "Faroe Islands", "ht" => "Haitian",
"fj" => "Fiji", "hu" => "Hungarian",
"fi" => "Finland", "hy" => "Armenian",
"fr" => "France", "hz" => "Herero",
"gf" => "French Guiana", "ia" => "Interlingua",
"pf" => "French Polynesia", "id" => "Indonesian",
"ga" => "Gabon", "ie" => "Interlingue",
"gm" => "Gambia", "ig" => "Igbo",
"ge" => "Georgia", "ii" => "Sichuan Yi",
"de" => "Germany", "ik" => "Inupiaq",
"gh" => "Ghana", "io" => "Ido",
"gi" => "Gibraltar", "is" => "Icelandic",
"gr" => "Greece", "it" => "Italian",
"gl" => "Greenland", "iu" => "Inuktitut",
"gd" => "Grenada", "ja" => "Japanese",
"gp" => "Guadeloupe", "jv" => "Javanese",
"gu" => "Guam", "ka" => "Georgian",
"gt" => "Guatemala", "kg" => "Kongo",
"gg" => "Guernsey", "ki" => "Kikuyu",
"gn" => "Guinea", "kj" => "Kuanyama",
"gy" => "Guyana", "kk" => "Kazakh",
"ht" => "Haiti", "kl" => "Kalaallisut",
"hn" => "Honduras", "km" => "Central Khmer",
"hk" => "Hong Kong", "kn" => "Kannada",
"hu" => "Hungary", "ko" => "Korean",
"is" => "Iceland", "kr" => "Kanuri",
"in" => "India", "ks" => "Kashmiri",
"id" => "Indonesia", "ku" => "Kurdish",
"iq" => "Iraq", "kv" => "Komi",
"ie" => "Ireland", "kw" => "Cornish",
"im" => "Isle of Man", "ky" => "Kyrgyz",
"il" => "Israel", "la" => "Latin",
"it" => "Italy", "lb" => "Luxembourgish",
"jm" => "Jamaica", "lg" => "Ganda",
"jp" => "Japan", "li" => "Limburgish",
"je" => "Jersey", "ln" => "Lingala",
"jo" => "Jordan", "lo" => "Lao",
"kz" => "Kazakhstan", "lt" => "Lithuanian",
"ke" => "Kenya", "lu" => "Luba-Katanga",
"ki" => "Kiribati", "lv" => "Latvian",
"kw" => "Kuwait", "mg" => "Malagasy",
"kg" => "Kyrgyzstan", "mh" => "Marshallese",
"la" => "Lao People's Democratic Republic", "mi" => "Maori",
"lv" => "Latvia", "mk" => "Macedonian",
"lb" => "Lebanon", "ml" => "Malayalam",
"ls" => "Lesotho", "mn" => "Mongolian",
"ly" => "Libya", "mr" => "Marathi",
"li" => "Liechtenstein", "ms" => "Malay",
"lt" => "Lithuania", "mt" => "Maltese",
"lu" => "Luxembourg", "my" => "Burmese",
"mk" => "Macedonia", "na" => "Nauru",
"mg" => "Madagascar", "nb" => "Norwegian Bokmål",
"mw" => "Malawi", "nd" => "North Ndebele",
"my" => "Malaysia", "ne" => "Nepali",
"mv" => "Maldives", "ng" => "Ndonga",
"ml" => "Mali", "nl" => "Dutch",
"mt" => "Malta", "nn" => "Norwegian Nynorsk",
"mq" => "Martinique", "no" => "Norwegian",
"mr" => "Mauritania", "nr" => "South Ndebele",
"mu" => "Mauritius", "nv" => "Navajo",
"yt" => "Mayotte", "ny" => "Chichewa",
"mx" => "Mexico", "oc" => "Occitan",
"fm" => "Micronesia, Federated States of", "oj" => "Ojibwa",
"md" => "Moldova", "om" => "Oromo",
"mc" => "Monaco", "or" => "Oriya",
"mn" => "Mongolia", "os" => "Ossetian",
"me" => "Montenegro", "pa" => "Punjabi",
"ms" => "Montserrat", "pi" => "Pali",
"ma" => "Morocco", "pl" => "Polish",
"mz" => "Mozambique", "ps" => "Pashto",
"mm" => "Myanmar", "pt" => "Portuguese",
"na" => "Namibia", "qu" => "Quechua",
"nr" => "Nauru", "rm" => "Romansh",
"np" => "Nepal", "rn" => "Rundi",
"nl" => "Netherlands", "ro" => "Romanian",
"nc" => "New Caledonia", "ru" => "Russian",
"nz" => "New Zealand", "rw" => "Kinyarwanda",
"ni" => "Nicaragua", "sa" => "Sanskrit",
"ne" => "Niger", "sc" => "Sardinian",
"ng" => "Nigeria", "sd" => "Sindhi",
"nu" => "Niue", "se" => "Northern Sami",
"no" => "Norway", "sg" => "Sango",
"om" => "Oman", "si" => "Sinhala",
"pk" => "Pakistan", "sk" => "Slovak",
"ps" => "Palestine, State of", "sl" => "Slovenian",
"pa" => "Panama", "sm" => "Samoan",
"pg" => "Papua New Guinea", "sn" => "Shona",
"py" => "Paraguay", "so" => "Somali",
"pe" => "Peru", "sq" => "Albanian",
"ph" => "Philippines", "sr" => "Serbian",
"pn" => "Pitcairn", "ss" => "Swati",
"pl" => "Poland", "st" => "Southern Sotho",
"pt" => "Portugal", "su" => "Sundanese",
"pr" => "Puerto Rico", "sv" => "Swedish",
"qa" => "Qatar", "sw" => "Swahili",
"ro" => "Romania", "ta" => "Tamil",
"ru" => "Russian Federation", "te" => "Telugu",
"rw" => "Rwanda", "tg" => "Tajik",
"re" => "Réunion", "th" => "Thai",
"sh" => "Saint Helena", "ti" => "Tigrinya",
"kn" => "Saint Kitts and Nevis", "tk" => "Turkmen",
"lc" => "Saint Lucia", "tl" => "Tagalog",
"vc" => "Saint Vincent and the Grenadines", "tn" => "Tswana",
"ws" => "Samoa",
"sm" => "San Marino",
"st" => "Sao Tome and Principe",
"sa" => "Saudi Arabia",
"sn" => "Senegal",
"rs" => "Serbia",
"sc" => "Seychelles",
"sl" => "Sierra Leone",
"sg" => "Singapore",
"sk" => "Slovakia",
"si" => "Slovenia",
"sb" => "Solomon Islands",
"so" => "Somalia",
"kr" => "Sourth Korea",
"za" => "South Africa",
"es" => "Spain",
"lk" => "Sri Lanka",
"sr" => "Suriname",
"se" => "Sweden",
"ch" => "Switzerland",
"tw" => "Taiwan",
"tj" => "Tajikistan",
"tz" => "Tanzania",
"th" => "Thailand",
"tl" => "Timor-Leste",
"tg" => "Togo",
"tk" => "Tokelau",
"to" => "Tonga", "to" => "Tonga",
"tt" => "Trinidad and Tobago", "tr" => "Turkish",
"tn" => "Tunisia", "ts" => "Tsonga",
"tr" => "Turkey", "tt" => "Tatar",
"tm" => "Turkmenistan", "tw" => "Twi",
"ug" => "Uganda", "ty" => "Tahitian",
"ua" => "Ukraine", "ug" => "Uyghur",
"ae" => "United Arab Emirates", "uk" => "Ukrainian",
"gb" => "United Kingdom", "ur" => "Urdu",
"us" => "United States", "uz" => "Uzbek",
"uy" => "Uruguay", "ve" => "Venda",
"uz" => "Uzbekistan", "vi" => "Vietnamese",
"vu" => "Vanuatu", "vo" => "Volapük",
"ve" => "Venezuela", "wa" => "Walloon",
"vn" => "Vietnam", "wo" => "Wolof",
"vg" => "Virgin Islands, British", "xh" => "Xhosa",
"vi" => "Virgin Islands, U.S.", "yi" => "Yiddish",
"ye" => "Yemen", "yo" => "Yoruba",
"zm" => "Zambia", "za" => "Zhuang",
"zw" => "Zimbabwe" "zh" => "Chinese",
"zh-cn" => "Chinese (Simplified)",
"zh-tw" => "Chinese (Traditional)",
"zu" => "Zulu"
] ]
], ],
"nsfw" => [ "nsfw" => [
"display" => "NSFW", "display" => "NSFW",
"option" => [ "option" => [
"yes" => "Yes", "yes" => "Yes",
"maybe" => "Maybe",
"no" => "No" "no" => "No"
] ]
] ]
@@ -301,16 +276,6 @@ class yep{
throw new Exception("Search term is empty!"); throw new Exception("Search term is empty!");
} }
$country = $get["country"];
$nsfw = $get["nsfw"];
switch($nsfw){
case "yes": $nsfw = "off"; break;
case "maybe": $nsfw = "moderate"; break;
case "no": $nsfw = "strict"; break;
}
$out = [ $out = [
"status" => "ok", "status" => "ok",
"spelling" => [ "spelling" => [
@@ -327,22 +292,23 @@ class yep{
"related" => [] "related" => []
]; ];
// parse filters
$filters = [
"limit" => 100, // wwwwwwwwwwwwwww
"query" => $search,
];
if($get["nsfw"] == "no"){ $filters["safeSearch"] = "moderate"; }
if($get["lang"] != "any"){ $filters["hl"] = $get["lang"]; }
try{ try{
// https://api.yep.com/fs/2/search?client=web&gl=CA&no_correct=false&q=undefined+variable+javascript&safeSearch=off&type=web // https://api.yep.com/fs/2/search?limit=20&query=asmr
$json = $json =
$this->get( $this->get(
$this->backend->get_ip(), $this->backend->get_ip(),
"https://api.yep.com/fs/2/search", "https://api.yep.com/fs/2/search",
[ $filters
"client" => "web",
"gl" => $country == "all" ? $country : strtoupper($country),
"limit" => "99999",
"no_correct" => "false",
"q" => $search,
"safeSearch" => $nsfw,
"type" => "web"
]
); );
}catch(Exception $error){ }catch(Exception $error){
@@ -408,7 +374,7 @@ class yep{
) )
), ),
"url" => $item["url"], "url" => $item["url"],
"date" => strtotime($item["first_seen"]), "date" => null,
"type" => "web", "type" => "web",
"thumb" => [ "thumb" => [
"url" => null, "url" => null,
@@ -422,265 +388,6 @@ class yep{
} }
} }
if(isset($json[1]["featured_news"])){
foreach($json[1]["featured_news"] as $news){
$out["news"][] = [
"title" => $news["title"],
"description" =>
$this->titledots(
strip_tags(
html_entity_decode(
$news["snippet"]
)
)
),
"date" => strtotime($news["first_seen"]),
"thumb" =>
isset($news["img"]) ?
[
"url" => $this->unshiturl($news["img"]),
"ratio" => "16:9"
] :
[
"url" => null,
"ratio" => null
],
"url" => $news["url"]
];
}
}
if(isset($json[1]["featured_images"])){
foreach($json[1]["featured_images"] as $image){
if(
$image["width"] !== 0 &&
$image["height"] !== 0
){
$thumb_width = $image["width"] >= 260 ? 260 : $image["width"];
$thumb_height = ceil($image["height"] * ($thumb_width / $image["width"]));
$width = $image["width"];
$height = $image["height"];
}else{
$thumb_width = null;
$thumb_height = null;
$width = null;
$height = null;
}
$out["image"][] = [
"title" => $image["title"],
"source" => [
[
"url" => $image["image_id"],
"width" => $width,
"height" => $height
],
[
"url" => $image["src"],
"width" => $thumb_width,
"height" => $thumb_height
]
],
"url" => $image["host_page"]
];
}
}
return $out;
}
public function image($get){
$search = $get["s"];
if(strlen($search) === 0){
throw new Exception("Search term is empty!");
}
$country = $get["country"];
$nsfw = $get["nsfw"];
switch($nsfw){
case "yes": $nsfw = "off"; break;
case "maybe": $nsfw = "moderate"; break;
case "no": $nsfw = "strict"; break;
}
$out = [
"status" => "ok",
"npt" => null,
"image" => []
];
try{
$json =
$this->get(
$this->backend->get_ip(), // no nextpage!
"https://api.yep.com/fs/2/search",
[
"client" => "web",
"gl" => $country == "all" ? $country : strtoupper($country),
"no_correct" => "false",
"q" => $search,
"safeSearch" => $nsfw,
"type" => "images"
]
);
}catch(Exception $error){
throw new Exception("Failed to fetch JSON");
}
$this->detect_cf($json);
$json = json_decode($json, true);
if($json === null){
throw new Exception("Failed to decode JSON");
}
if(isset($json[1]["results"])){
foreach($json[1]["results"] as $item){
if(
$item["width"] !== 0 &&
$item["height"] !== 0
){
$thumb_width = $item["width"] >= 260 ? 260 : $item["width"];
$thumb_height = ceil($item["height"] * ($thumb_width / $item["width"]));
$width = $item["width"];
$height = $item["height"];
}else{
$thumb_width = null;
$thumb_height = null;
$width = null;
$height = null;
}
$out["image"][] = [
"title" => $item["title"],
"source" => [
[
"url" => $item["image_id"],
"width" => $width,
"height" => $height
],
[
"url" => $item["src"],
"width" => $thumb_width,
"height" => $thumb_height
]
],
"url" => $item["host_page"]
];
}
}
return $out;
}
public function news($get){
$search = $get["s"];
if(strlen($search) === 0){
throw new Exception("Search term is empty!");
}
$country = $get["country"];
$nsfw = $get["nsfw"];
switch($nsfw){
case "yes": $nsfw = "off"; break;
case "maybe": $nsfw = "moderate"; break;
case "no": $nsfw = "strict"; break;
}
$out = [
"status" => "ok",
"npt" => null,
"news" => []
];
try{
// https://api.yep.com/fs/2/search?client=web&gl=CA&no_correct=false&q=undefined+variable+javascript&safeSearch=off&type=web
$json =
$this->get(
$this->backend->get_ip(),
"https://api.yep.com/fs/2/search",
[
"client" => "web",
"gl" => $country == "all" ? $country : strtoupper($country),
"limit" => "99999",
"no_correct" => "false",
"q" => $search,
"safeSearch" => $nsfw,
"type" => "news"
]
);
}catch(Exception $error){
throw new Exception("Failed to fetch JSON");
}
$this->detect_cf($json);
$json = json_decode($json, true);
//$json = json_decode(file_get_contents("scraper/yep.json"), true);
if($json === null){
throw new Exception("Failed to decode JSON");
}
if(isset($json[1]["results"])){
foreach($json[1]["results"] as $item){
$out["news"][] = [
"title" => $item["title"],
"author" => null,
"description" =>
$this->titledots(
strip_tags(
html_entity_decode(
$item["snippet"]
)
)
),
"date" => strtotime($item["first_seen"]),
"thumb" =>
isset($item["img"]) ?
[
"url" => $this->unshiturl($item["img"]),
"ratio" => "16:9"
] :
[
"url" => null,
"ratio" => null
],
"url" => $item["url"]
];
}
}
return $out; return $out;
} }

View File

@@ -243,10 +243,6 @@ $settings = [
"value" => "qwant", "value" => "qwant",
"text" => "Qwant" "text" => "Qwant"
], ],
[
"value" => "yep",
"text" => "Yep"
],
[ [
"value" => "baidu", "value" => "baidu",
"text" => "Baidu" "text" => "Baidu"
@@ -383,10 +379,6 @@ $settings = [
"value" => "qwant", "value" => "qwant",
"text" => "Qwant" "text" => "Qwant"
], ],
[
"value" => "yep",
"text" => "Yep"
],
[ [
"value" => "mojeek", "value" => "mojeek",
"text" => "Mojeek" "text" => "Mojeek"