use better api path
This commit is contained in:
1 parent
aad3083cec
commit
155d769f4b
2 files changed
+144
-247
No files matched your search
@@ -282,7 +282,7 @@ function get_proxy(proxy_line){
|
|||||||
|
|
||||||
fplay.event.on("server_ready", function(){
|
fplay.event.on("server_ready", function(){
|
||||||
|
|
||||||
console.log("listening on port " + config.port + " (timeout=" + config.timeout + ")");
|
console.log("4play interface listening on port " + config.port_4play + " (timeout=" + config.timeout + ")");
|
||||||
});
|
});
|
||||||
|
|
||||||
fplay.event.on("browser_connect", async function(ws){
|
fplay.event.on("browser_connect", async function(ws){
|
||||||
|
|||||||
+143
-246
@@ -138,7 +138,7 @@ class yandex{
|
|||||||
"Accept-Encoding: gzip",
|
"Accept-Encoding: gzip",
|
||||||
"Accept-Language: en-US,en;q=0.5",
|
"Accept-Language: en-US,en;q=0.5",
|
||||||
"DNT: 1",
|
"DNT: 1",
|
||||||
($session !== null ? "Cookie: {$session}" : null),
|
($session !== null ? "Cookie: {$session}" : "Cookie: yp=" . (time() - random_int(3000000, 4000000)) . ".szm.1:1920x1080:876x1000#" . time() . ".sp.family:{$nsfw}"),
|
||||||
"Referer: https://yandex.com/images/search",
|
"Referer: https://yandex.com/images/search",
|
||||||
"Connection: keep-alive",
|
"Connection: keep-alive",
|
||||||
"Upgrade-Insecure-Requests: 1",
|
"Upgrade-Insecure-Requests: 1",
|
||||||
@@ -674,96 +674,42 @@ class yandex{
|
|||||||
$json = fread($handle, filesize("scraper/yandex.json"));
|
$json = fread($handle, filesize("scraper/yandex.json"));
|
||||||
fclose($handle);*/
|
fclose($handle);*/
|
||||||
|
|
||||||
// SIZE
|
// https://yandex.com/images/search
|
||||||
// large
|
// ?tmpl_version=releases-frontend-images-v1.1907.0__a0cb31dc1f0f45dcc1749ab4c8e2c2306f77697c
|
||||||
// 227.0=1;203.0=1;76fe94.0=1;41d251.0=1;75.0=1;371.0=1;291.0=1;307.0=1;f797ee.0=1;1cf7c2.0=1;deca32.0=1"},"extraContent":{"names":["i-react-ajax-adapter"]}}}&yu=4861394161661655015&isize=large&suggest_reqid=486139416166165501540886508227485&text=minecraft&uinfo=sw-1920-sh-1080-ww-1125-wh-999-pd-1-wp-16x9_1920x1080
|
// &format=json
|
||||||
|
// &request=%7B%22blocks%22%3A%5B%7B%22block%22%3A%22extra-content%22%2C%22params%22%3A%7B%7D%2C%22version%22%3A2%7D%2C%7B%22block%22%3A%7B%22block%22%3A%22i-react-ajax-adapter%3Aajax%22%7D%2C%22params%22%3A%7B%22type%22%3A%22ImagesApp%22%2C%22ajaxKey%22%3A%22serpList%2Ffetch%22%7D%2C%22version%22%3A2%7D%5D%7D
|
||||||
// medium
|
// &yu=3091577281773194415
|
||||||
// 227.0=1;203.0=1;76fe94.0=1;41d251.0=1;75.0=1;371.0=1;291.0=1;307.0=1;f797ee.0=1;1cf7c2.0=1;deca32.0=1"},"extraContent":{"names":["i-react-ajax-adapter"]}}}&yu=4861394161661655015&isize=medium&suggest_reqid=486139416166165501540886508227485&text=minecraft&uinfo=sw-1920-sh-1080-ww-1125-wh-999-pd-1-wp-16x9_1920x1080
|
// &from=tabbar
|
||||||
|
// &images_pagination=CocEEoAEAAAAAIkAAAAAAAAAgAAA4GAAgAAAAAAAgAABIAAAIAAAJAAAAAAgAAAAAQAMARACAAAQAAQAAAEEEAAAhAEAAAAgAAAAAAAAAAAAEAAAAAAAAAAABABAAAAAAAEAABAAAAAAAAAAAAAAAAAAAAIAgAAFAEAQAAAAAAEBEAAAAAEBAAABAAlAAAAIAAAAASQAIIACgAIAAAAACAEACQEAAAAAACAAAQAIABAAAgAIAUAAIAAQAIAAAAAAAAAAAAACAIAgAAAAAAEEQIAEAgACCQAAAAAAAABAIAAAAAAAEkAAAEAAAAAAAQAAQACAEAAAAAIAAEAACAAAAAAAQAAAgAAAggAAIEAAKAiAAAAAAAAAAAGABAAAAEEAAAAAAAAAIAAAIAABAAAAABAAiAACAAAAAgAoIAAIgAAAAAMAAAAAAACAAAAAAAAAgAACAAAAAAAgAAAAAKAABAgAAAAAAAAAAAAQgAAAAoAAAQAAAAAAAABAAAAAAAAAMAAAFAAAAAABAAAAAQBIAACAIIAQAACAAAAAAggAAICAAAkAAgAAAAAAAAAAACAAABCAAAAAgCBAAIAgAAAAAQAAAgCABABQAAQAAAAAAAAAAAgQAAIAAQAABAAAAAAAAABAAAAAAAAAAACAAAAIAgAgAAAAAAAAgAAAAAAAAAAAAIAAEAAYKCAB
|
||||||
// small
|
// &serpListType=horizontal
|
||||||
// 227.0=1;203.0=1;76fe94.0=1;41d251.0=1;75.0=1;371.0=1;291.0=1;307.0=1;f797ee.0=1;1cf7c2.0=1;deca32.0=1"},"extraContent":{"names":["i-react-ajax-adapter"]}}}&yu=4861394161661655015&isize=small&suggest_reqid=486139416166165501540886508227485&text=minecraft&uinfo=sw-1920-sh-1080-ww-1125-wh-999-pd-1-wp-16x9_1920x1080
|
// &serpid=_6RI0KRHmknuwEJ3BjRy7w
|
||||||
|
// &text=higurashi+wallpapers
|
||||||
// ORIENTATION
|
// &uinfo=sw-1920-sh-1080-ww-1305-wh-997-pd-1-wp-16x9_1920x1080
|
||||||
// Horizontal
|
|
||||||
// 227.0=1;203.0=1;76fe94.0=1;41d251.0=1;75.0=1;371.0=1;291.0=1;307.0=1;f797ee.0=1;1cf7c2.0=1;deca32.0=1"},"extraContent":{"names":["i-react-ajax-adapter"]}}}&yu=4861394161661655015&iorient=horizontal&suggest_reqid=486139416166165501540886508227485&text=minecraft&uinfo=sw-1920-sh-1080-ww-1125-wh-999-pd-1-wp-16x9_1920x1080
|
|
||||||
|
|
||||||
// Vertical
|
|
||||||
// 227.0=1;203.0=1;76fe94.0=1;41d251.0=1;75.0=1;371.0=1;291.0=1;307.0=1;f797ee.0=1;1cf7c2.0=1;deca32.0=1"},"extraContent":{"names":["i-react-ajax-adapter"]}}}&yu=4861394161661655015&iorient=vertical&suggest_reqid=486139416166165501540886508227485&text=minecraft&uinfo=sw-1920-sh-1080-ww-1125-wh-999-pd-1-wp-16x9_1920x1080
|
|
||||||
|
|
||||||
// Square
|
|
||||||
// 227.0=1;203.0=1;76fe94.0=1;41d251.0=1;75.0=1;371.0=1;291.0=1;307.0=1;f797ee.0=1;1cf7c2.0=1;deca32.0=1"},"extraContent":{"names":["i-react-ajax-adapter"]}}}&yu=4861394161661655015&iorient=square&suggest_reqid=486139416166165501540886508227485&text=minecraft&uinfo=sw-1920-sh-1080-ww-1125-wh-999-pd-1-wp-16x9_1920x1080
|
|
||||||
|
|
||||||
// TYPE
|
|
||||||
// Photos
|
|
||||||
// 307.0=1;371.0=1;291.0=1;203.0=1;deca32.0=1;f797ee.0=1;1cf7c2.0=1;41d251.0=1;267.0=1;bde197.0=1"},"extraContent":{"names":["i-react-ajax-adapter"]}}}&yu=4861394161661655015&text=minecraft&type=photo&uinfo=sw-1920-sh-1080-ww-1125-wh-999-pd-1-wp-16x9_1920x1080
|
|
||||||
|
|
||||||
// White background
|
|
||||||
// 307.0=1;371.0=1;291.0=1;203.0=1;deca32.0=1;f797ee.0=1;1cf7c2.0=1;41d251.0=1;267.0=1;bde197.0=1"},"extraContent":{"names":["i-react-ajax-adapter"]}}}&yu=4861394161661655015&text=minecraft&type=clipart&uinfo=sw-1920-sh-1080-ww-1125-wh-999-pd-1-wp-16x9_1920x1080
|
|
||||||
|
|
||||||
// Drawings and sketches
|
|
||||||
// 307.0=1;371.0=1;291.0=1;203.0=1;deca32.0=1;f797ee.0=1;1cf7c2.0=1;41d251.0=1;267.0=1;bde197.0=1"},"extraContent":{"names":["i-react-ajax-adapter"]}}}&yu=4861394161661655015&text=minecraft&type=lineart&uinfo=sw-1920-sh-1080-ww-1125-wh-999-pd-1-wp-16x9_1920x1080
|
|
||||||
|
|
||||||
// People
|
|
||||||
// 307.0=1;371.0=1;291.0=1;203.0=1;deca32.0=1;f797ee.0=1;1cf7c2.0=1;41d251.0=1;267.0=1;bde197.0=1"},"extraContent":{"names":["i-react-ajax-adapter"]}}}&yu=4861394161661655015&text=minecraft&type=face&uinfo=sw-1920-sh-1080-ww-1125-wh-999-pd-1-wp-16x9_1920x1080
|
|
||||||
|
|
||||||
// Demotivators
|
|
||||||
// 307.0=1;371.0=1;291.0=1;203.0=1;deca32.0=1;f797ee.0=1;1cf7c2.0=1;41d251.0=1;267.0=1;bde197.0=1"},"extraContent":{"names":["i-react-ajax-adapter"]}}}&yu=4861394161661655015&text=minecraft&type=demotivator&uinfo=sw-1920-sh-1080-ww-1125-wh-999-pd-1-wp-16x9_1920x1080
|
|
||||||
|
|
||||||
// COLOR
|
|
||||||
// Color images only
|
|
||||||
// 307.0=1;371.0=1;291.0=1;203.0=1;deca32.0=1;f797ee.0=1;1cf7c2.0=1;41d251.0=1;267.0=1;bde197.0=1"},"extraContent":{"names":["i-react-ajax-adapter"]}}}&yu=4861394161661655015&icolor=color&text=minecraft&uinfo=sw-1920-sh-1080-ww-1125-wh-999-pd-1-wp-16x9_1920x1080
|
|
||||||
|
|
||||||
// Black and white
|
|
||||||
// 307.0=1;371.0=1;291.0=1;203.0=1;deca32.0=1;f797ee.0=1;1cf7c2.0=1;41d251.0=1;267.0=1;bde197.0=1"},"extraContent":{"names":["i-react-ajax-adapter"]}}}&yu=4861394161661655015&icolor=gray&text=minecraft&uinfo=sw-1920-sh-1080-ww-1125-wh-999-pd-1-wp-16x9_1920x1080
|
|
||||||
|
|
||||||
// Red
|
|
||||||
// 307.0=1;371.0=1;291.0=1;203.0=1;deca32.0=1;f797ee.0=1;1cf7c2.0=1;41d251.0=1;267.0=1;bde197.0=1"},"extraContent":{"names":["i-react-ajax-adapter"]}}}&yu=4861394161661655015&icolor=red&text=minecraft&uinfo=sw-1920-sh-1080-ww-1125-wh-999-pd-1-wp-16x9_1920x1080
|
|
||||||
|
|
||||||
// Orange
|
|
||||||
// 307.0=1;371.0=1;291.0=1;203.0=1;deca32.0=1;f797ee.0=1;1cf7c2.0=1;41d251.0=1;267.0=1;bde197.0=1"},"extraContent":{"names":["i-react-ajax-adapter"]}}}&yu=4861394161661655015&icolor=orange&text=minecraft&uinfo=sw-1920-sh-1080-ww-1125-wh-999-pd-1-wp-16x9_1920x1080
|
|
||||||
|
|
||||||
// Yellow
|
|
||||||
// 307.0=1;371.0=1;291.0=1;203.0=1;deca32.0=1;f797ee.0=1;1cf7c2.0=1;41d251.0=1;267.0=1;bde197.0=1"},"extraContent":{"names":["i-react-ajax-adapter"]}}}&yu=4861394161661655015&icolor=yellow&text=minecraft&uinfo=sw-1920-sh-1080-ww-1125-wh-999-pd-1-wp-16x9_1920x1080
|
|
||||||
|
|
||||||
// Cyan
|
|
||||||
// 307.0=1;371.0=1;291.0=1;203.0=1;deca32.0=1;f797ee.0=1;1cf7c2.0=1;41d251.0=1;267.0=1;bde197.0=1"},"extraContent":{"names":["i-react-ajax-adapter"]}}}&yu=4861394161661655015&icolor=cyan&text=minecraft&uinfo=sw-1920-sh-1080-ww-1125-wh-999-pd-1-wp-16x9_1920x1080
|
|
||||||
|
|
||||||
// Green
|
|
||||||
// 307.0=1;371.0=1;291.0=1;203.0=1;deca32.0=1;f797ee.0=1;1cf7c2.0=1;41d251.0=1;267.0=1;bde197.0=1"},"extraContent":{"names":["i-react-ajax-adapter"]}}}&yu=4861394161661655015&icolor=green&text=minecraft&uinfo=sw-1920-sh-1080-ww-1125-wh-999-pd-1-wp-16x9_1920x1080
|
|
||||||
|
|
||||||
// Blue
|
|
||||||
// 307.0=1;371.0=1;291.0=1;203.0=1;deca32.0=1;f797ee.0=1;1cf7c2.0=1;41d251.0=1;267.0=1;bde197.0=1"},"extraContent":{"names":["i-react-ajax-adapter"]}}}&yu=4861394161661655015&icolor=blue&text=minecraft&uinfo=sw-1920-sh-1080-ww-1125-wh-999-pd-1-wp-16x9_1920x1080
|
|
||||||
|
|
||||||
// Purple
|
|
||||||
// 307.0=1;371.0=1;291.0=1;203.0=1;deca32.0=1;f797ee.0=1;1cf7c2.0=1;41d251.0=1;267.0=1;bde197.0=1"},"extraContent":{"names":["i-react-ajax-adapter"]}}}&yu=4861394161661655015&icolor=violet&text=minecraft&uinfo=sw-1920-sh-1080-ww-1125-wh-999-pd-1-wp-16x9_1920x1080
|
|
||||||
|
|
||||||
// White
|
|
||||||
// 307.0=1;371.0=1;291.0=1;203.0=1;deca32.0=1;f797ee.0=1;1cf7c2.0=1;41d251.0=1;267.0=1;bde197.0=1"},"extraContent":{"names":["i-react-ajax-adapter"]}}}&yu=4861394161661655015&icolor=white&text=minecraft&uinfo=sw-1920-sh-1080-ww-1125-wh-999-pd-1-wp-16x9_1920x1080
|
|
||||||
|
|
||||||
// Black
|
|
||||||
// 307.0=1;371.0=1;291.0=1;203.0=1;deca32.0=1;f797ee.0=1;1cf7c2.0=1;41d251.0=1;267.0=1;bde197.0=1"},"extraContent":{"names":["i-react-ajax-adapter"]}}}&yu=4861394161661655015&icolor=black&text=minecraft&uinfo=sw-1920-sh-1080-ww-1125-wh-999-pd-1-wp-16x9_1920x1080
|
|
||||||
|
|
||||||
// FORMAT
|
|
||||||
// jpeg
|
|
||||||
// 307.0=1;371.0=1;291.0=1;203.0=1;deca32.0=1;f797ee.0=1;1cf7c2.0=1;41d251.0=1;267.0=1;bde197.0=1"},"extraContent":{"names":["i-react-ajax-adapter"]}}}&yu=4861394161661655015&itype=jpg&text=minecraft&uinfo=sw-1920-sh-1080-ww-1125-wh-999-pd-1-wp-16x9_1920x1080
|
|
||||||
|
|
||||||
// png
|
|
||||||
// 307.0=1;371.0=1;291.0=1;203.0=1;deca32.0=1;f797ee.0=1;1cf7c2.0=1;41d251.0=1;267.0=1;bde197.0=1"},"extraContent":{"names":["i-react-ajax-adapter"]}}}&yu=4861394161661655015&itype=png&text=minecraft&uinfo=sw-1920-sh-1080-ww-1125-wh-999-pd-1-wp-16x9_1920x1080
|
|
||||||
|
|
||||||
// gif
|
|
||||||
// 307.0=1;371.0=1;291.0=1;203.0=1;deca32.0=1;f797ee.0=1;1cf7c2.0=1;41d251.0=1;267.0=1;bde197.0=1"},"extraContent":{"names":["i-react-ajax-adapter"]}}}&yu=4861394161661655015&itype=gifan&text=minecraft&uinfo=sw-1920-sh-1080-ww-1125-wh-999-pd-1-wp-16x9_1920x1080
|
|
||||||
|
|
||||||
// RECENT
|
|
||||||
// 307.0=1;371.0=1;291.0=1;203.0=1;deca32.0=1;f797ee.0=1;1cf7c2.0=1;41d251.0=1;267.0=1;bde197.0=1"},"extraContent":{"names":["i-react-ajax-adapter"]}}}&yu=4861394161661655015&recent=7D&text=minecraft&uinfo=sw-1920-sh-1080-ww-1125-wh-999-pd-1-wp-16x9_1920x1080
|
|
||||||
|
|
||||||
// WALLPAPER
|
|
||||||
// 307.0=1;371.0=1;291.0=1;203.0=1;deca32.0=1;f797ee.0=1;1cf7c2.0=1;41d251.0=1;267.0=1;bde197.0=1"},"extraContent":{"names":["i-react-ajax-adapter"]}}}&yu=4861394161661655015&isize=wallpaper&text=minecraft&wp=wh16x9_1920x1080&uinfo=sw-1920-sh-1080-ww-1125-wh-999-pd-1-wp-16x9_1920x1080
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
{"blocks":[
|
||||||
|
{
|
||||||
|
"block":"extra-content",
|
||||||
|
"params":{},
|
||||||
|
"version":2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"block":{
|
||||||
|
"block":"i-react-ajax-adapter:ajax"
|
||||||
|
},
|
||||||
|
"params":{
|
||||||
|
"type":"ImagesApp",
|
||||||
|
"ajaxKey":"serpList/fetch"
|
||||||
|
},
|
||||||
|
"version":2
|
||||||
|
}
|
||||||
|
]}
|
||||||
|
*/
|
||||||
|
|
||||||
$request = [
|
$request = [
|
||||||
|
"tmpl_version" => "releases-frontend-images-v1.1907.0__a0cb31dc1f0f45dcc1749ab4c8e2c2306f77697c",
|
||||||
"format" => "json",
|
"format" => "json",
|
||||||
"request" => [
|
"request" => json_encode([
|
||||||
"blocks" => [
|
"blocks" => [
|
||||||
[
|
[
|
||||||
"block" => "extra-content",
|
"block" => "extra-content",
|
||||||
@@ -771,59 +717,22 @@ class yandex{
|
|||||||
"version" => 2
|
"version" => 2
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"block" => "i-global__params:ajax",
|
"block" => [
|
||||||
"params" => (object)[],
|
"block" => "i-react-ajax-adapter:ajax"
|
||||||
|
],
|
||||||
|
"params" => [
|
||||||
|
"type" => "ImagesApp",
|
||||||
|
"ajaxKey" => "serpList/fetch",
|
||||||
|
],
|
||||||
"version" => 2
|
"version" => 2
|
||||||
],
|
],
|
||||||
[
|
|
||||||
"block" => "search2:ajax",
|
|
||||||
"params" => (object)[],
|
|
||||||
"version" => 2
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"block" => "preview__isWallpaper",
|
|
||||||
"params" => (object)[],
|
|
||||||
"version" => 2
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"block" => "content_type_search",
|
|
||||||
"params" => (object)[],
|
|
||||||
"version" => 2
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"block" => "serp-controller",
|
|
||||||
"params" => (object)[],
|
|
||||||
"version" => 2
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"block" => "cookies_ajax",
|
|
||||||
"params" => (object)[],
|
|
||||||
"version" => 2
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"block" => "advanced-search-block",
|
|
||||||
"params" => (object)[],
|
|
||||||
"version" => 2
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"metadata" => [
|
|
||||||
"bundles" => [
|
|
||||||
"lb" => "AS?(E<X120"
|
|
||||||
],
|
|
||||||
"assets" => [
|
|
||||||
// las base
|
|
||||||
"las" => "justifier-height=1;justifier-setheight=1;fitimages-height=1;justifier-fitincuts=1;react-with-dom=1;"
|
|
||||||
|
|
||||||
// las default
|
|
||||||
//"las" => "justifier-height=1;justifier-setheight=1;fitimages-height=1;justifier-fitincuts=1;react-with-dom=1;227.0=1;203.0=1;76fe94.0=1;215f96.0=1;75.0=1"
|
|
||||||
],
|
|
||||||
"extraContent" => [
|
|
||||||
"names" => [
|
|
||||||
"i-react-ajax-adapter"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
]
|
]
|
||||||
]
|
]),
|
||||||
|
"from" => "tabbar",
|
||||||
|
//"images_pagination" =>
|
||||||
|
"serpListType" => "horizontal",
|
||||||
|
"text" => $search,
|
||||||
|
"uinfo" => "sw-1920-sh-1080-ww-1305-wh-997-pd-1-wp-16x9_1920x1080"
|
||||||
];
|
];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -857,11 +766,6 @@ class yandex{
|
|||||||
|
|
||||||
$request["itype"] = $format;
|
$request["itype"] = $format;
|
||||||
}
|
}
|
||||||
|
|
||||||
$request["text"] = $search;
|
|
||||||
$request["uinfo"] = "sw-1920-sh-1080-ww-1125-wh-999-pd-1-wp-16x9_1920x1080";
|
|
||||||
|
|
||||||
$request["request"] = json_encode($request["request"]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try{
|
try{
|
||||||
@@ -934,122 +838,115 @@ class yandex{
|
|||||||
"image" => []
|
"image" => []
|
||||||
];
|
];
|
||||||
|
|
||||||
// get html
|
$keys = false;
|
||||||
$html = "";
|
$ref = 0;
|
||||||
|
|
||||||
|
// get keys
|
||||||
foreach($json["blocks"] as $block){
|
foreach($json["blocks"] as $block){
|
||||||
|
|
||||||
$html .= $block["html"];
|
if(isset($block["params"]["adapterData"]["serpList"]["items"]["keys"])){
|
||||||
// get next page
|
|
||||||
if(
|
|
||||||
isset($block["params"]["nextPageUrl"]) &&
|
|
||||||
!empty($block["params"]["nextPageUrl"])
|
|
||||||
){
|
|
||||||
|
|
||||||
$request["nsfw"] = $nsfw;
|
$keys = &$block["params"]["adapterData"]["serpList"]["items"]["keys"];
|
||||||
$request["session"] = $session;
|
$ref++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!is_array($keys)){
|
||||||
|
|
||||||
|
throw new Exception("Failed to find keys to iterate over");
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($keys as $key){
|
||||||
|
|
||||||
|
$target = &$json["blocks"][$ref]["params"]["adapterData"]["serpList"]["items"]["entities"][$key];
|
||||||
|
|
||||||
|
$sources = [];
|
||||||
|
|
||||||
|
foreach(
|
||||||
|
array_merge(
|
||||||
|
$target["viewerData"]["preview"],
|
||||||
|
$target["viewerData"]["dups"]
|
||||||
|
)
|
||||||
|
as $image){
|
||||||
|
|
||||||
if(isset($request["p"])){
|
// remove dups
|
||||||
|
foreach($sources as $source){
|
||||||
|
|
||||||
$request["p"]++;
|
if($source["url"] == $image["url"]){ continue 2; }
|
||||||
}else{
|
|
||||||
|
|
||||||
$request["p"] = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$out["npt"] =
|
// add
|
||||||
$this->backend->store(
|
$sources[] = [
|
||||||
json_encode($request),
|
"url" => $image["url"],
|
||||||
"images",
|
"width" => (int)$image["w"],
|
||||||
$proxy
|
"height" => (int)$image["h"]
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->fuckhtml->load($html);
|
|
||||||
|
|
||||||
// get search results
|
|
||||||
$data = null;
|
|
||||||
|
|
||||||
foreach(
|
|
||||||
$this->fuckhtml
|
|
||||||
->getElementsByClassName(
|
|
||||||
"Root",
|
|
||||||
"div"
|
|
||||||
) as $div
|
|
||||||
){
|
|
||||||
|
|
||||||
if(isset($div["attributes"]["data-state"])){
|
|
||||||
|
|
||||||
$tmp = json_decode(
|
|
||||||
$this->fuckhtml
|
|
||||||
->getTextContent(
|
|
||||||
$div["attributes"]["data-state"]
|
|
||||||
),
|
|
||||||
true
|
|
||||||
);
|
|
||||||
|
|
||||||
if(isset($tmp["initialState"]["serpList"])){
|
|
||||||
|
|
||||||
$data = $tmp;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if($data === null){
|
|
||||||
|
|
||||||
throw new Exception("Failed to extract JSON");
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach($data["initialState"]["serpList"]["items"]["entities"] as $image){
|
|
||||||
|
|
||||||
$title = [html_entity_decode($image["snippet"]["title"], ENT_QUOTES | ENT_HTML5)];
|
|
||||||
|
|
||||||
if(isset($image["snippet"]["text"])){
|
|
||||||
|
|
||||||
$title[] = html_entity_decode($image["snippet"]["text"], ENT_QUOTES | ENT_HTML5);
|
|
||||||
}
|
|
||||||
|
|
||||||
$tmp = [
|
|
||||||
"title" =>
|
|
||||||
$this->fuckhtml
|
|
||||||
->getTextContent(
|
|
||||||
$this->titledots(
|
|
||||||
implode(": ", $title)
|
|
||||||
)
|
|
||||||
),
|
|
||||||
"source" => [],
|
|
||||||
"url" => htmlspecialchars_decode($image["snippet"]["url"])
|
|
||||||
];
|
|
||||||
|
|
||||||
// add preview URL
|
|
||||||
$tmp["source"][] = [
|
|
||||||
"url" => htmlspecialchars_decode($image["viewerData"]["preview"][0]["url"]),
|
|
||||||
"width" => (int)$image["viewerData"]["preview"][0]["w"],
|
|
||||||
"height" => (int)$image["viewerData"]["preview"][0]["h"],
|
|
||||||
];
|
|
||||||
|
|
||||||
foreach($image["viewerData"]["dups"] as $dup){
|
|
||||||
|
|
||||||
$tmp["source"][] = [
|
|
||||||
"url" => htmlspecialchars_decode($dup["url"]),
|
|
||||||
"width" => (int)$dup["w"],
|
|
||||||
"height" => (int)$dup["h"],
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$tmp["source"][] = [
|
// sort by image size
|
||||||
"url" =>
|
usort($sources, fn($a, $b) => $b["width"] <=> $a["width"]);
|
||||||
preg_replace(
|
|
||||||
'/^\/\//',
|
// add thumbnail
|
||||||
"https://",
|
$sources[] = [
|
||||||
htmlspecialchars_decode($image["viewerData"]["thumb"]["url"])
|
"url" => "https:" . $target["viewerData"]["thumb"]["url"],
|
||||||
),
|
"width" => (int)$target["viewerData"]["thumb"]["w"],
|
||||||
"width" => (int)$image["viewerData"]["thumb"]["w"],
|
"height" => (int)$target["viewerData"]["thumb"]["h"]
|
||||||
"height" => (int)$image["viewerData"]["thumb"]["h"]
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$out["image"][] = $tmp;
|
$title = [];
|
||||||
|
|
||||||
|
if(
|
||||||
|
isset($target["snippet"]["title"]) &&
|
||||||
|
!empty($target["snippet"]["title"])
|
||||||
|
){
|
||||||
|
|
||||||
|
$title[] =
|
||||||
|
$this->titledots(
|
||||||
|
$target["snippet"]["title"]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(
|
||||||
|
isset($target["viewerData"]["snippet"]["text"]) &&
|
||||||
|
!empty($target["viewerData"]["snippet"]["text"])
|
||||||
|
){
|
||||||
|
|
||||||
|
$title[] =
|
||||||
|
$this->titledots(
|
||||||
|
strip_tags(
|
||||||
|
$target["viewerData"]["snippet"]["text"]
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$out["image"][] = [
|
||||||
|
"title" => implode(": ", $title),
|
||||||
|
"source" => $sources,
|
||||||
|
"url" => $target["snippet"]["url"]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// get npt
|
||||||
|
if(isset($json["blocks"][$ref]["params"]["adapterData"]["serpList"]["navi"]["next"])){
|
||||||
|
|
||||||
|
if(!isset($request["p"])){
|
||||||
|
|
||||||
|
$request["p"] = 1;
|
||||||
|
}else{
|
||||||
|
|
||||||
|
$request["p"]++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$request["nsfw"] = $nsfw;
|
||||||
|
$request["session"] = $session;
|
||||||
|
|
||||||
|
$out["npt"] =
|
||||||
|
$this->backend->store(
|
||||||
|
json_encode($request),
|
||||||
|
"image",
|
||||||
|
$proxy
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $out;
|
return $out;
|
||||||
|
|||||||
Reference in new issue
Block a user