Skip to content

Commit

Permalink
[EconomistWorldInBriefBridge] Fix bridge (RSS-Bridge#4258)
Browse files Browse the repository at this point in the history
  • Loading branch information
SqrtMinusOne authored Sep 7, 2024
1 parent 293d04f commit 358bebb
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions bridges/EconomistWorldInBriefBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,21 @@ public function collectData()
];
}
$html = getSimpleHTMLDOM(self::URI, $headers);
$gobbets = $html->find('._gobbets', 0);
$gobbets = $html->find('p[data-component="the-world-in-brief-paragraph"]');
if ($this->getInput('splitGobbets') == 1) {
$this->splitGobbets($gobbets);
} else {
$this->mergeGobbets($gobbets);
};
if ($this->getInput('agenda') == 1) {
$articles = $html->find('._articles', 0);
$articles = $html->find('div[data-test-id="chunks"] > div > div', 0);

if ($articles != null) {
$this->collectArticles($articles);
}
}
if ($this->getInput('quote') == 1) {
$quote = $html->find('._quote-container', 0);
$quote = $html->find('blockquote[data-test-id="inspirational-quote"]', 0);
$this->addQuote($quote);
}
}
Expand All @@ -83,7 +84,7 @@ private function splitGobbets($gobbets)
$today = new Datetime();
$today->setTime(0, 0, 0, 0);
$limit = $this->getInput('limit');
foreach ($gobbets->find('._gobbet') as $gobbet) {
foreach ($gobbets as $gobbet) {
$title = $gobbet->plaintext;
$match = preg_match('/[\.,]/', $title, $matches, PREG_OFFSET_CAPTURE);
if ($match > 0) {
Expand All @@ -109,7 +110,7 @@ private function mergeGobbets($gobbets)
$today = new Datetime();
$today->setTime(0, 0, 0, 0);
$contents = '';
foreach ($gobbets->find('._gobbet') as $gobbet) {
foreach ($gobbets as $gobbet) {
$contents .= "<p>{$gobbet->innertext}";
}
$this->items[] = [
Expand All @@ -126,10 +127,14 @@ private function collectArticles($articles)
$i = 0;
$today = new Datetime();
$today->setTime(0, 0, 0, 0);
foreach ($articles->find('._article') as $article) {
$title = $article->find('._headline', 0)->plaintext;
$image = $article->find('._main-image', 0);
$content = $article->find('._content', 0);
foreach ($articles->children() as $element) {
if ($element->tag != 'div') {
continue;
}
$image = $element->find('figure', 0);
$title = $element->find('h3', 0)->plaintext;
$content = $element->find('h3', 0)->parent();
$content->find('h3', 0)->outertext = '';

$res_content = '';
if ($image != null && $this->getInput('agendaPictures') == 1) {
Expand Down

0 comments on commit 358bebb

Please sign in to comment.