1
0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2025-08-22 08:03:52 +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

@@ -29,16 +29,16 @@ class EconomistBridge extends BridgeAbstract {
// Remove newsletter subscription box
$newsletter = $content->find('div[class="newsletter-form__message"]', 0);
if ($newsletter)
$newsletter->outertext = '';
$newsletter->remove();
$newsletterForm = $content->find('form', 0);
if ($newsletterForm)
$newsletterForm->outertext = '';
$newsletterForm->remove();
// Remove next and previous article URLs at the bottom
$nextprev = $content->find('div[class="blog-post__next-previous-wrapper"]', 0);
if ($nextprev)
$nextprev->outertext = '';
$nextprev->remove();
$section = [ $article->find('h3[itemprop="articleSection"]', 0)->plaintext ];