2022-01-17 08:35:01 +03:00
|
|
|
<?php
|
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
class ABCNewsBridge extends BridgeAbstract
|
|
|
|
{
|
|
|
|
const NAME = 'ABC News Bridge';
|
|
|
|
const URI = 'https://www.abc.net.au';
|
|
|
|
const DESCRIPTION = 'Topics of the Australian Broadcasting Corporation';
|
|
|
|
const MAINTAINER = 'yue-dongchen';
|
2022-01-17 08:35:01 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
const PARAMETERS = [
|
|
|
|
[
|
|
|
|
'topic' => [
|
|
|
|
'type' => 'list',
|
|
|
|
'name' => 'Region',
|
|
|
|
'title' => 'Choose state',
|
|
|
|
'values' => [
|
|
|
|
'ACT' => 'act',
|
|
|
|
'NSW' => 'nsw',
|
|
|
|
'NT' => 'nt',
|
|
|
|
'QLD' => 'qld',
|
|
|
|
'SA' => 'sa',
|
|
|
|
'TAS' => 'tas',
|
|
|
|
'VIC' => 'vic',
|
|
|
|
'WA' => 'wa'
|
|
|
|
],
|
|
|
|
]
|
|
|
|
]
|
|
|
|
];
|
2022-01-17 08:35:01 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
public function collectData()
|
|
|
|
{
|
2022-09-13 20:00:51 +03:00
|
|
|
$url = sprintf('https://www.abc.net.au/news/%s', $this->getInput('topic'));
|
|
|
|
$dom = getSimpleHTMLDOM($url);
|
2024-08-31 17:27:45 +03:00
|
|
|
$dom = $dom->find('div[data-component="PaginationList"]', 0);
|
2022-09-13 20:00:51 +03:00
|
|
|
if (!$dom) {
|
|
|
|
throw new \Exception(sprintf('Unable to find css selector on `%s`', $url));
|
|
|
|
}
|
|
|
|
$dom = defaultLinkTo($dom, $this->getURI());
|
2024-08-31 17:27:45 +03:00
|
|
|
foreach ($dom->find('article[data-component="DetailCard"]') as $article) {
|
2022-09-13 20:00:51 +03:00
|
|
|
$a = $article->find('a', 0);
|
|
|
|
$this->items[] = [
|
|
|
|
'title' => $a->plaintext,
|
|
|
|
'uri' => $a->href,
|
2024-08-31 17:27:45 +03:00
|
|
|
'content' => $article->find('p', 0)->plaintext,
|
2022-09-13 20:00:51 +03:00
|
|
|
'timestamp' => strtotime($article->find('time', 0)->datetime),
|
|
|
|
];
|
2022-07-01 16:10:30 +03:00
|
|
|
}
|
|
|
|
}
|
2022-01-17 08:35:01 +03:00
|
|
|
}
|