Improve type-safety of wikidata fetcher
This commit is contained in:
parent
e91dfbf3ef
commit
7dde870afb
|
@ -343,30 +343,34 @@ final class NodaWikidataFetcher {
|
||||||
$list = $doc->getElementsByTagName("style");
|
$list = $doc->getElementsByTagName("style");
|
||||||
while ($list->length > 0) {
|
while ($list->length > 0) {
|
||||||
$p = $list->item(0);
|
$p = $list->item(0);
|
||||||
|
if ($p === null || $p->parentNode === null) break;
|
||||||
$p->parentNode->removeChild($p);
|
$p->parentNode->removeChild($p);
|
||||||
}
|
}
|
||||||
|
|
||||||
$list = $doc->getElementsByTagName("table");
|
$list = $doc->getElementsByTagName("table");
|
||||||
while ($list->length > 0) {
|
while ($list->length > 0) {
|
||||||
$p = $list->item(0);
|
$p = $list->item(0);
|
||||||
|
if ($p === null || $p->parentNode === null) break;
|
||||||
$p->parentNode->removeChild($p);
|
$p->parentNode->removeChild($p);
|
||||||
}
|
}
|
||||||
|
|
||||||
$list = $doc->getElementsByTagName("div");
|
$list = $doc->getElementsByTagName("div");
|
||||||
while ($list->length > 1) {
|
while ($list->length > 1) {
|
||||||
$p = $list->item(1);
|
$p = $list->item(1);
|
||||||
|
if ($p === null || $p->parentNode === null) break;
|
||||||
$p->parentNode->removeChild($p);
|
$p->parentNode->removeChild($p);
|
||||||
}
|
}
|
||||||
|
|
||||||
$list = $doc->getElementsByTagName("ol");
|
$list = $doc->getElementsByTagName("ol");
|
||||||
while ($list->length > 0) {
|
while ($list->length > 0) {
|
||||||
$p = $list->item(0);
|
$p = $list->item(0);
|
||||||
|
if ($p === null || $p->parentNode === null) break;
|
||||||
$p->parentNode->removeChild($p);
|
$p->parentNode->removeChild($p);
|
||||||
}
|
}
|
||||||
|
|
||||||
$firstP = $doc->getElementsByTagName("p")->item(0);
|
$firstP = $doc->getElementsByTagName("p")->item(0);
|
||||||
if (strpos($doc->saveHTML($firstP), 'geohack') !== false) {
|
if (strpos($doc->saveHTML($firstP), 'geohack') !== false) {
|
||||||
$firstP->parentNode->removeChild($firstP);
|
if ($firstP !== null && $firstP->parentNode !== null) $firstP->parentNode->removeChild($firstP);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue
Block a user