parent
c5f59aaeb9
commit
944f6c731b
1 changed files with 79 additions and 12 deletions
|
|
@ -196,7 +196,7 @@ class marginalia{
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function web($get){
|
public function web($get, $ss = ""){
|
||||||
|
|
||||||
$search = [$get["s"]];
|
$search = [$get["s"]];
|
||||||
if(strlen($get["s"]) === 0){
|
if(strlen($get["s"]) === 0){
|
||||||
|
|
@ -390,28 +390,35 @@ class marginalia{
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
$params = [
|
|
||||||
"query" => $search
|
|
||||||
];
|
|
||||||
|
|
||||||
foreach(["adtech", "recent", "intitle"] as $v){
|
if($ss == ""){
|
||||||
|
|
||||||
if($get[$v] == "yes"){
|
$params = [
|
||||||
|
"query" => $search
|
||||||
|
];
|
||||||
|
|
||||||
switch($v){
|
foreach(["adtech", "recent", "intitle"] as $v){
|
||||||
|
|
||||||
case "adtech": $params["adtech"] = "reduce"; break;
|
if($get[$v] == "yes"){
|
||||||
case "recent": $params["recent"] = "recent"; break;
|
|
||||||
case "adtech": $params["searchTitle"] = "title"; break;
|
switch($v){
|
||||||
|
|
||||||
|
case "adtech": $params["adtech"] = "reduce"; break;
|
||||||
|
case "recent": $params["recent"] = "recent"; break;
|
||||||
|
case "adtech": $params["searchTitle"] = "title"; break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
|
||||||
|
$params = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
try{
|
try{
|
||||||
$html =
|
$html =
|
||||||
$this->get(
|
$this->get(
|
||||||
$proxy,
|
$proxy,
|
||||||
"https://old-search.marginalia.nu/search",
|
"https://old-search.marginalia.nu/search" . $ss,
|
||||||
$params,
|
$params,
|
||||||
//$anubis_key
|
//$anubis_key
|
||||||
);
|
);
|
||||||
|
|
@ -423,6 +430,66 @@ class marginalia{
|
||||||
|
|
||||||
$this->fuckhtml->load($html);
|
$this->fuckhtml->load($html);
|
||||||
|
|
||||||
|
// detect meta redirect
|
||||||
|
$title =
|
||||||
|
$this->fuckhtml
|
||||||
|
->getElementsByTagName(
|
||||||
|
"title"
|
||||||
|
);
|
||||||
|
|
||||||
|
if(
|
||||||
|
count($title) !== 0 &&
|
||||||
|
$this->fuckhtml
|
||||||
|
->getTextContent(
|
||||||
|
$title[0]
|
||||||
|
) == "Error"
|
||||||
|
){
|
||||||
|
|
||||||
|
// redirect detected
|
||||||
|
|
||||||
|
// get timeout
|
||||||
|
$timeout =
|
||||||
|
$this->fuckhtml
|
||||||
|
->getElementById(
|
||||||
|
"countdown",
|
||||||
|
"b"
|
||||||
|
);
|
||||||
|
|
||||||
|
if(count($timeout) === null){
|
||||||
|
|
||||||
|
throw new Exception("Failed to find timeout value");
|
||||||
|
}
|
||||||
|
|
||||||
|
$timeout =
|
||||||
|
$this->fuckhtml
|
||||||
|
->getTextContent(
|
||||||
|
$timeout
|
||||||
|
);
|
||||||
|
|
||||||
|
preg_match(
|
||||||
|
'/location\.replace\(\'([^\']+)\'\)/',
|
||||||
|
$html,
|
||||||
|
$redirect
|
||||||
|
);
|
||||||
|
|
||||||
|
if(!isset($redirect[1])){
|
||||||
|
|
||||||
|
throw new Exception("Failed to grep redirect value");
|
||||||
|
}
|
||||||
|
|
||||||
|
$one = 1;
|
||||||
|
$redirect =
|
||||||
|
str_replace(
|
||||||
|
"/search",
|
||||||
|
"",
|
||||||
|
$redirect[1],
|
||||||
|
$one
|
||||||
|
);
|
||||||
|
|
||||||
|
sleep((int)$timeout);
|
||||||
|
return $this->web($get, $redirect);
|
||||||
|
}
|
||||||
|
|
||||||
$sections =
|
$sections =
|
||||||
$this->fuckhtml
|
$this->fuckhtml
|
||||||
->getElementsByClassName(
|
->getElementsByClassName(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue