From 42d0252e2ff1d15a4adfee9fef0decee6aefcccb Mon Sep 17 00:00:00 2001 From: lolcat Date: Wed, 28 Oct 2026 22:59:45 -0400 Subject: [PATCH] handle failed redirect fetches --- scraper/google.php | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/scraper/google.php b/scraper/google.php index 104de77..f64ae84 100644 --- a/scraper/google.php +++ b/scraper/google.php @@ -706,20 +706,29 @@ class google{ if(count($a) === 0){ - throw new Exception("Failed to find link"); + // failed to find link, will serve a resolver target as fallback + $fallback = true; + $slug = explode("url=", $this->handles[$i]["replacement"]); + $link = "/resolver?scraper=google&target=" . rawurlencode($slug[1]); + }else{ + + $fallback = false; + $link = + $this->fuckhtml + ->getTextContent( + $a[0]["attributes"]["href"] + ); } - $link = - $this->fuckhtml - ->getTextContent( - $a[0]["attributes"]["href"] - ); - if( - preg_match( - '/^(https?:|)\/\//', - $link - ) + ( + $fallback === false && + preg_match( + '/^(https?:|)\/\//', + $link + ) + ) || + $fallback === true ){ $keys[] = $this->handles[$i]["replacement"];