mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-04-23 15:06:53 +00:00
[CdactionBridge] Add new bridge (#2431)
This commit is contained in:
parent
c1c998dd13
commit
09fac3aa35
31
bridges/CdactionBridge.php
Normal file
31
bridges/CdactionBridge.php
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class CdactionBridge extends BridgeAbstract {
|
||||||
|
const NAME = 'CD-ACTION bridge';
|
||||||
|
const URI = 'https://cdaction.pl/newsy';
|
||||||
|
const DESCRIPTION = 'Fetches the latest news.';
|
||||||
|
const MAINTAINER = 'tomaszkane';
|
||||||
|
|
||||||
|
public function collectData() {
|
||||||
|
$html = getSimpleHTMLDOM($this->getURI());
|
||||||
|
|
||||||
|
$newsJson = $html->find('script#__NEXT_DATA__', 0)->innertext;
|
||||||
|
if (!$newsJson = json_decode($newsJson)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($newsJson->props->pageProps->dehydratedState->queries[1]->state->data->results as $news) {
|
||||||
|
$item = array();
|
||||||
|
$item['uri'] = $this->getURI() . '/' . $news->slug;
|
||||||
|
$item['title'] = $news->title;
|
||||||
|
$item['timestamp'] = $news->publishedAt;
|
||||||
|
$item['author'] = $news->editor->fullName;
|
||||||
|
$item['content'] = $news->lead;
|
||||||
|
$item['enclosures'][] = $news->bannerUrl;
|
||||||
|
$item['categories'] = array_column($news->tags, 'name');
|
||||||
|
$item['uid'] = $news->id;
|
||||||
|
|
||||||
|
$this->items[] = $item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user