Selaa lähdekoodia

fix invalid sublinks on google scraper

lolcat 9 kuukautta sitten
vanhempi
sitoutus
46e6ed12e3
1 muutettua tiedostoa jossa 26 lisäystä ja 16 poistoa
  1. 26 16
      scraper/google.php

+ 26 - 16
scraper/google.php

@@ -953,23 +953,33 @@ class google{
 						])
 					);
 				
-				if(count($probe) !== 0){
+				$url =
+					$this->unshiturl(
+						$a["attributes"]["href"]
+					);
+				
+				if(
+					preg_match(
+						'/^http/',
+						$url
+					)
+				){
 					
-					$sublinks[] = [
-						"title" =>
-							$this->titledots(
-								$this->fuckhtml
-								->getTextContent(
-									$probe[0]
-								)
-							),
-						"description" => null,
-						"date" => null,
-						"url" =>
-							$this->unshiturl(
-								$a["attributes"]["href"]
-							)
-					];
+					if(count($probe) !== 0){
+						
+						$sublinks[] = [
+							"title" =>
+								$this->titledots(
+									$this->fuckhtml
+									->getTextContent(
+										$probe[0]
+									)
+								),
+							"description" => null,
+							"date" => null,
+							"url" => $url
+						];
+					}
 				}
 			}