Skip to content

Commit

Permalink
[CarThrottleBridge] update for new layout
Browse files Browse the repository at this point in the history
  • Loading branch information
t0stiman committed Oct 6, 2024
1 parent 80c43f1 commit 32c961c
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions bridges/CarThrottleBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,31 +80,22 @@ private function getArticles($category)

$item['author'] = $this->parseAuthor($articlePage);

$articleElement = $articlePage->find('article')[0];
$articleImage = $articlePage->find('div.block-layout-field-image')[0];
$article = $articlePage->find('div.block-layout-body')[1];

//remove ads
foreach ($articleElement->find('aside') as $ad) {
foreach ($article->find('aside') as $ad) {
$ad->outertext = '';
}

$summary = $articleElement->find('div.summary')[0];

//remove header so we are left with the article content
foreach ($articleElement->find('header') as $found) {
$found->outertext = '';
}

//remove comments (registering on carthrottle.com is impossible so the comment sections are empty anyway)
foreach ($articleElement->find('#lbs-comments') as $found) {
$found->outertext = '';
}
$summary = $articlePage->find('div.summary')[0];

//these are supposed to be hidden
foreach ($articleElement->find('.visually-hidden') as $found) {
foreach ($article->find('.visually-hidden') as $found) {
$found->outertext = '';
}

$item['content'] = $summary . $articleElement;
$item['content'] = $summary . $articleImage . $article;

array_push($this->items, $item);
}
Expand All @@ -117,7 +108,7 @@ private function parseAuthor($articlePage)
return '';
}

$a = $authorDivs[0]->find('a');
$a = $authorDivs[0]->find('a')[0];
if ($a) {
return $a->innertext;
}
Expand Down

0 comments on commit 32c961c

Please sign in to comment.