handle cucked urls on google
This commit is contained in:
1 parent
36b1deb485
commit
0e5258a1b9
1 file changed
+91
-26
+91
-26
@@ -891,7 +891,7 @@ class google{
|
||||
$html = &$data["data"];
|
||||
$container = &$data["container"];
|
||||
//file_put_contents("scraper/google-jp.html", $html);
|
||||
//$html = file_get_contents("scraper/google.html");
|
||||
//$html = file_get_contents("scraper/doc1.html");
|
||||
//$container = "";
|
||||
}
|
||||
|
||||
@@ -1263,8 +1263,36 @@ class google{
|
||||
$this->fuckhtml
|
||||
->getElementsByTagName("cite");
|
||||
|
||||
$cuckurl = null;
|
||||
|
||||
if(isset($cite[0])){
|
||||
|
||||
//
|
||||
// get cucked URL
|
||||
//
|
||||
$cite_conv =
|
||||
$this->fuckhtml
|
||||
->getTextContent(
|
||||
$cite[0]
|
||||
);
|
||||
|
||||
// is it a cucked URL?
|
||||
if(
|
||||
preg_match(
|
||||
'/^http/',
|
||||
$cite_conv
|
||||
) !== 0
|
||||
){
|
||||
|
||||
// https://www.sleepfoundation.org › ... › ASMR for Sleep
|
||||
$cuckurl =
|
||||
preg_replace(
|
||||
'/ *› */',
|
||||
"/",
|
||||
$cite_conv
|
||||
);
|
||||
}
|
||||
|
||||
$texts =
|
||||
explode(
|
||||
" · ",
|
||||
@@ -1298,12 +1326,72 @@ class google{
|
||||
continue;
|
||||
}
|
||||
|
||||
// anything else?
|
||||
// table elements
|
||||
$table[ucfirst($probe[2])] = trim($probe[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($cuckurl === null){
|
||||
|
||||
// failed to get a valid URL
|
||||
// lets create some make believe URL
|
||||
|
||||
$website_name =
|
||||
$this->fuckhtml
|
||||
->getElementsByClassName(
|
||||
$this->getstyle([
|
||||
"color" => "var(" . $this->getcolorvar("#16171a") . ")",
|
||||
"font-size" => "var(--zng88)",
|
||||
"display" => "block",
|
||||
"line-height" => "20px",
|
||||
"white-space" => "nowrap",
|
||||
"overflow-x" => "hidden",
|
||||
"text-overflow" => "ellipsis",
|
||||
"width" => "auto",
|
||||
"font-family" => "google sans,sans-serif"
|
||||
]),
|
||||
"span"
|
||||
);
|
||||
|
||||
if(count($website_name) !== 0){
|
||||
|
||||
$website_name =
|
||||
html_entity_decode(
|
||||
$website_name[0]["innerHTML"]
|
||||
);
|
||||
|
||||
$website_name = explode("·", $website_name, 2);
|
||||
|
||||
// replacing spaces should take care of "stack overflow"
|
||||
$website_domain =
|
||||
str_replace(
|
||||
" ",
|
||||
"",
|
||||
trim(
|
||||
strtolower(
|
||||
$website_name[0]
|
||||
),
|
||||
" \t\n\r\0\x0B\xC2\xA0"
|
||||
)
|
||||
);
|
||||
|
||||
// @todo find more TLDs, but i think theres just twitch thats weird
|
||||
switch($website_domain){
|
||||
|
||||
case "twitch": $website_domain = "twitch.tv"; break;
|
||||
default: $website_domain = "{$website_domain}.com";
|
||||
}
|
||||
|
||||
$cuckurl = "https://" . $website_domain;
|
||||
|
||||
if(isset($website_name[1])){
|
||||
|
||||
$cuckurl .= "/" . trim($website_name[1], " \t\n\r\0\x0B\xC2\xA0");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// get description/image wrapper
|
||||
$desc_img_wrappers =
|
||||
$this->fuckhtml
|
||||
@@ -1374,30 +1462,6 @@ class google{
|
||||
|
||||
$t = trim(html_entity_decode($t));
|
||||
|
||||
if(preg_match("/\p{Sc}/u", $t)){
|
||||
|
||||
$table["Price"] = $t;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(str_contains($t, "stock")){
|
||||
|
||||
$table["Stock"] = $t;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(str_contains($t, "return")){
|
||||
|
||||
$table["Returns"] = $t;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(str_contains($t, "delivery")){
|
||||
|
||||
$table["Delivery"] = $t;
|
||||
continue;
|
||||
}
|
||||
|
||||
// 5.0(590,004)
|
||||
if(preg_match('/^([0-9kmb\/%.,]+) *(\([0-9kmb,.]+\))?/', $t, $match)){
|
||||
|
||||
@@ -1475,6 +1539,7 @@ class google{
|
||||
"title" => $title,
|
||||
"description" => $description,
|
||||
"url" => $this->convert_goto_to_resolver($url),
|
||||
"cuckurl" => $cuckurl,
|
||||
"date" => $date,
|
||||
"type" => "web",
|
||||
"thumb" => $thumb,
|
||||
|
||||
Reference in new issue
Block a user