handle failed redirect fetches
This commit is contained in:
1 parent
a27a8ed01a
commit
42d0252e2f
1 file changed
+20
-11
+20
-11
@@ -706,20 +706,29 @@ class google{
|
|||||||
|
|
||||||
if(count($a) === 0){
|
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(
|
if(
|
||||||
preg_match(
|
(
|
||||||
'/^(https?:|)\/\//',
|
$fallback === false &&
|
||||||
$link
|
preg_match(
|
||||||
)
|
'/^(https?:|)\/\//',
|
||||||
|
$link
|
||||||
|
)
|
||||||
|
) ||
|
||||||
|
$fallback === true
|
||||||
){
|
){
|
||||||
|
|
||||||
$keys[] = $this->handles[$i]["replacement"];
|
$keys[] = $this->handles[$i]["replacement"];
|
||||||
|
|||||||
Reference in new issue
Block a user