mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-08-03 17:44:48 +02:00
parent
7dbe106582
commit
fac1f5cd88
2 changed files with 44 additions and 66 deletions
|
@ -1,11 +1,35 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* See https://reporterre.net/spip.php?page=backend-simple
|
||||
*/
|
||||
class ReporterreBridge extends BridgeAbstract
|
||||
{
|
||||
const MAINTAINER = 'nyutag';
|
||||
const NAME = 'Reporterre Bridge';
|
||||
const URI = 'https://www.reporterre.net/';
|
||||
const DESCRIPTION = 'Returns the newest articles.';
|
||||
const DESCRIPTION = 'Returns the newest articles. See also their official feed https://reporterre.net/spip.php?page=backend-simple';
|
||||
|
||||
public function collectData()
|
||||
{
|
||||
//$url = self::URI . 'spip.php?page=backend';
|
||||
$url = self::URI . 'spip.php?page=backend-simple';
|
||||
$html = getSimpleHTMLDOM($url);
|
||||
$limit = 0;
|
||||
|
||||
foreach ($html->find('item') as $element) {
|
||||
if ($limit < 5) {
|
||||
$item = [];
|
||||
$item['title'] = html_entity_decode($element->find('title', 0)->plaintext);
|
||||
$item['timestamp'] = strtotime($element->find('dc:date', 0)->plaintext);
|
||||
$item['uri'] = $element->find('guid', 0)->innertext;
|
||||
//$item['content'] = html_entity_decode($this->extractContent($item['uri']));
|
||||
$item['content'] = htmlspecialchars_decode($element->find('description', 0)->plaintext);
|
||||
$this->items[] = $item;
|
||||
$limit++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function extractContent($url)
|
||||
{
|
||||
|
@ -22,22 +46,4 @@ class ReporterreBridge extends BridgeAbstract
|
|||
$text = strip_tags($text, '<p><br><a><img>');
|
||||
return $text;
|
||||
}
|
||||
|
||||
public function collectData()
|
||||
{
|
||||
$html = getSimpleHTMLDOM(self::URI . 'spip.php?page=backend');
|
||||
$limit = 0;
|
||||
|
||||
foreach ($html->find('item') as $element) {
|
||||
if ($limit < 5) {
|
||||
$item = [];
|
||||
$item['title'] = html_entity_decode($element->find('title', 0)->plaintext);
|
||||
$item['timestamp'] = strtotime($element->find('dc:date', 0)->plaintext);
|
||||
$item['uri'] = $element->find('guid', 0)->innertext;
|
||||
$item['content'] = html_entity_decode($this->extractContent($item['uri']));
|
||||
$this->items[] = $item;
|
||||
$limit++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue