Improve type-safety of wikidata fetcher

This commit is contained in:
Joshua Ramon Enslin 2022-04-13 00:16:05 +02:00
parent e91dfbf3ef
commit 7dde870afb
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE

View File

@ -343,30 +343,34 @@ final class NodaWikidataFetcher {
$list = $doc->getElementsByTagName("style");
while ($list->length > 0) {
$p = $list->item(0);
if ($p === null || $p->parentNode === null) break;
$p->parentNode->removeChild($p);
}
$list = $doc->getElementsByTagName("table");
while ($list->length > 0) {
$p = $list->item(0);
if ($p === null || $p->parentNode === null) break;
$p->parentNode->removeChild($p);
}
$list = $doc->getElementsByTagName("div");
while ($list->length > 1) {
$p = $list->item(1);
if ($p === null || $p->parentNode === null) break;
$p->parentNode->removeChild($p);
}
$list = $doc->getElementsByTagName("ol");
while ($list->length > 0) {
$p = $list->item(0);
if ($p === null || $p->parentNode === null) break;
$p->parentNode->removeChild($p);
}
$firstP = $doc->getElementsByTagName("p")->item(0);
if (strpos($doc->saveHTML($firstP), 'geohack') !== false) {
$firstP->parentNode->removeChild($firstP);
if ($firstP !== null && $firstP->parentNode !== null) $firstP->parentNode->removeChild($firstP);
}
/*