diff options
author | 2022-11-25 20:39:56 +0100 | |
---|---|---|
committer | 2022-11-25 20:39:56 +0100 | |
commit | 9863204fa38d387326a0a22b5980a1010c59e8f5 (patch) | |
tree | 5d003bef75e005bdb11e0c80491be783ce6f9b42 | |
parent | 592ea8faa45ecad6b6df4c16a4850d634bbd3b2a (diff) | |
download | rss-bridge-9863204fa38d387326a0a22b5980a1010c59e8f5.tar.gz rss-bridge-9863204fa38d387326a0a22b5980a1010c59e8f5.tar.zst rss-bridge-9863204fa38d387326a0a22b5980a1010c59e8f5.zip |
Feat: Add bridge for Vpro tegenlicht (#3162)
* [VproTegenlichtBridge.php] Created bridge
* [VproTegenlichtBridge.php] Added fetch exception
-rw-r--r-- | bridges/VproTegenlichtBridge.php | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/bridges/VproTegenlichtBridge.php b/bridges/VproTegenlichtBridge.php new file mode 100644 index 00000000..3a71f9f0 --- /dev/null +++ b/bridges/VproTegenlichtBridge.php @@ -0,0 +1,43 @@ +<?php + +class VproTegenlichtBridge extends BridgeAbstract +{ + const MAINTAINER = 'vincentvd'; + const NAME = 'VPRO tegenlicht'; + const URI = 'https://www.vpro.nl/programmas/tegenlicht/lees/artikelen.html'; + const CACHE_TIMEOUT = 900; // 15 minutes + const DESCRIPTION = 'RSS feed for the VPRO tegenlicht website'; + + public function getIcon() + { + return 'https://www.vpro.nl/.resources/vpro/favicons/vpro/favicon.ico'; + } + + public function collectData() + { + $url = sprintf('https://www.vpro.nl/programmas/tegenlicht/lees/artikelen.html'); + $dom = getSimpleHTMLDOM($url) + or returnServerError('No contents received!'); + $dom = $dom->find('ul#browsable-news-overview', 0); + + $dom = defaultLinkTo($dom, $this->getURI()); + foreach ($dom->find('li') as $article) { + $a = $article->find('a.complex-teaser', 0); + $title = $article->find('a.complex-teaser', 0)->title; + $url = $article->find('a.complex-teaser', 0)->href; + $author = "VPRO tegenlicht"; + $content = $article->find('p.complex-teaser-summary', 0)->plaintext; + $timestamp = strtotime($article->find('div.complex-teaser-data', 0)->plaintext); + + $item = [ + 'uri' => $url, + 'author' => $author, + 'title' => $title, + 'timestamp' => $timestamp, + 'content' => $content + ]; + + $this->items[] = $item; + } + } +} |