fix: broken bridge abcnews (#3033)

Fix #3031
This commit is contained in:
Dag 2022-09-13 19:00:51 +02:00 committed by GitHub
parent 2d272117cc
commit 6f7be67a8c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -29,20 +29,21 @@ class ABCNewsBridge extends BridgeAbstract
public function collectData() public function collectData()
{ {
$url = 'https://www.abc.net.au/news/' . $this->getInput('topic'); $url = sprintf('https://www.abc.net.au/news/%s', $this->getInput('topic'));
$html = getSimpleHTMLDOM($url)->find('.YAJzu._2FvRw.ZWhbj._3BZxh', 0); $dom = getSimpleHTMLDOM($url);
$html = defaultLinkTo($html, $this->getURI()); $dom = $dom->find('div[data-component="CardList"]', 0);
if (!$dom) {
foreach ($html->find('._2H7Su') as $article) { throw new \Exception(sprintf('Unable to find css selector on `%s`', $url));
$item = []; }
$dom = defaultLinkTo($dom, $this->getURI());
$title = $article->find('._3T9Id.fmhNa.nsZdE._2c2Zy._1tOey._3EOTW', 0); foreach ($dom->find('div[data-component="GenericCard"]') as $article) {
$item['title'] = $title->plaintext; $a = $article->find('a', 0);
$item['uri'] = $title->href; $this->items[] = [
$item['content'] = $article->find('.rMkro._1cBaI._3PhF6._10YQT._1yL-m', 0)->plaintext; 'title' => $a->plaintext,
$item['timestamp'] = strtotime($article->find('time', 0)->datetime); 'uri' => $a->href,
'content' => $article->find('[data-component="CardDescription"]', 0)->plaintext,
$this->items[] = $item; 'timestamp' => strtotime($article->find('time', 0)->datetime),
];
} }
} }
} }