diff options
| author | lolcat <will@lolcat.ca> | 2026-06-14 16:01:56 -0400 |
|---|---|---|
| committer | lolcat <will@lolcat.ca> | 2026-06-14 16:01:56 -0400 |
| commit | d87bac94b5290fb49ba97e97d805caa3a93ef569 (patch) | |
| tree | d23bea047accf10628f0e29af3f9a1d86d84f278 | |
| parent | d54e4dfcddf5625527188d6a687742b699a33a54 (diff) | |
handle marginalia internal error
| -rw-r--r-- | scraper/marginalia.php | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/scraper/marginalia.php b/scraper/marginalia.php index f5be5e1..90b7f4c 100644 --- a/scraper/marginalia.php +++ b/scraper/marginalia.php @@ -490,6 +490,37 @@ class marginalia{ return $this->web($get, $redirect); } + // detect internal error + $infobox = + $this->fuckhtml + ->getElementsByClassName("infobox"); + + if(count($infobox) !== 0){ + + foreach($infobox as $i){ + + $this->fuckhtml->load($i); + + $h2 = + $this->fuckhtml + ->getElementsByTagName("h2"); + + if( + count($h2) !== 0 && + $this->fuckhtml + ->getTextContent( + $h2[0] + ) == "Internal error" + ){ + + throw new Exception("Marginalia returned an internal server error"); + } + } + + // reset + $this->fuckhtml->load($html); + } + $sections = $this->fuckhtml ->getElementsByClassName( |
