diff --git a/src/Readability.php b/src/Readability.php index 6bcbf78d..e7736492 100644 --- a/src/Readability.php +++ b/src/Readability.php @@ -1076,7 +1076,7 @@ private function rateNodes($nodes) $scoreThreshold = $lastScore / 3; /* @var DOMElement $parentOfTopCandidate */ - while ($parentOfTopCandidate->nodeName !== 'body') { + while (!is_null($parentOfTopCandidate) && $parentOfTopCandidate->nodeName !== 'body') { $parentScore = $parentOfTopCandidate->contentScore; if ($parentScore < $scoreThreshold) { break;