rss-bridge/bridges/ABCNewsBridge.php

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

49 lines
1.5 KiB
PHP
Raw Normal View History

2022-01-17 08:35:01 +03:00
<?php
class ABCNewsBridge extends BridgeAbstract
{
2022-01-17 08:35:01 +03:00
const NAME = 'ABC News Bridge';
const URI = 'https://www.abc.net.au';
const DESCRIPTION = 'Topics of the Australian Broadcasting Corporation';
const MAINTAINER = 'yue-dongchen';
const PARAMETERS = [
[
2022-01-17 08:35:01 +03:00
'topic' => [
'type' => 'list',
'name' => 'Region',
'title' => 'Choose state',
'values' => [
'ACT' => 'act',
'NSW' => 'nsw',
'NT' => 'nt',
2022-03-25 03:41:40 +03:00
'QLD' => 'qld',
2022-01-17 08:35:01 +03:00
'SA' => 'sa',
'TAS' => 'tas',
'VIC' => 'vic',
'WA' => 'wa'
],
]
]
2022-01-17 08:35:01 +03:00
];
public function collectData()
{
$url = 'https://www.abc.net.au/news/' . $this->getInput('topic');
$html = getSimpleHTMLDOM($url)->find('.YAJzu._2FvRw.ZWhbj._3BZxh', 0);
$html = defaultLinkTo($html, $this->getURI());
foreach ($html->find('._2H7Su') as $article) {
$item = [];
$title = $article->find('._3T9Id.fmhNa.nsZdE._2c2Zy._1tOey._3EOTW', 0);
$item['title'] = $title->plaintext;
$item['uri'] = $title->href;
$item['content'] = $article->find('.rMkro._1cBaI._3PhF6._10YQT._1yL-m', 0)->plaintext;
$item['timestamp'] = strtotime($article->find('time', 0)->datetime);
2022-01-17 08:35:01 +03:00
$this->items[] = $item;
}
}
2022-01-17 08:35:01 +03:00
}