1
0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2025-07-31 22:00:23 +02:00

all: Use ->remove() instead of ->outertext = ''

simplehtmldom 1.9 introduced new functions to recursively remove
nodes from the DOM. This allows removing elements without the need
to re-load the document by using $html->load($html->save()), which
is very inefficient.

Find more information about remove() at
https://simplehtmldom.sourceforge.io/docs/1.9/api/simple_html_dom_node/remove/
This commit is contained in:
logmanoriginal
2019-06-01 21:15:30 +02:00
parent 014b698f67
commit 052844f5e1
21 changed files with 44 additions and 49 deletions

View File

@@ -141,7 +141,7 @@ class WikipediaBridge extends BridgeAbstract {
$anchorFallbackIndex = 0){
// Clean the bottom of the featured article
if ($element->find('div', -1))
$element->find('div', -1)->outertext = '';
$element->find('div', -1)->remove();
// The title and URI of the article can be found in an anchor containing
// the string '...' in most wikis ('full article ...')
@@ -202,10 +202,10 @@ class WikipediaBridge extends BridgeAbstract {
// Let's remove a couple of things from the article
$table = $content->find('#toc', 0); // Table of contents
if(!$table === false)
$table->outertext = '';
$table->remove();
foreach($content->find('ol.references') as $reference) // References
$reference->outertext = '';
$reference->remove();
return str_replace('href="/', 'href="' . $this->getURI() . '/', $content->innertext);
}