mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-08-01 00:25:09 +02:00
bridges: use BridgeAbstract::getSimpleHTMLDOM
instead of BridgeAbstract::file_get_html Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
This commit is contained in:
parent
f43bbda83e
commit
3c0d13c1bb
121 changed files with 1212 additions and 396 deletions
69
bridges/FrandroidBridge.php
Normal file
69
bridges/FrandroidBridge.php
Normal file
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
class FrandroidBridge extends BridgeAbstract
|
||||
{
|
||||
public function loadMetadatas() {
|
||||
|
||||
$this->maintainer = "Daiyousei";
|
||||
$this->name = "Frandroid";
|
||||
$this->uri = "http://www.frandroid.com/";
|
||||
$this->description = "Returns the RSS feed from Frandroid (full text articles)";
|
||||
$this->update = "2015-03-05";
|
||||
|
||||
}
|
||||
|
||||
public function collectData(array $param)
|
||||
{
|
||||
|
||||
function FrandroidStripCDATA($string)
|
||||
{
|
||||
$string = str_replace('<![CDATA[', '', $string);
|
||||
$string = str_replace(']]>', '', $string);
|
||||
return $string;
|
||||
}
|
||||
function FrandroidExtractContent($url)
|
||||
{
|
||||
$html2 = $this->getSimpleHTMLDOM($url);
|
||||
$html3 = $html2->find('div.post-content', 0);
|
||||
$html3->find('div.no-sidebar-ad-top', 0)->outertext = '';
|
||||
$ret = $html3->find('div.shortcode-container');
|
||||
foreach ($ret as $value) {
|
||||
$value->outertext = '';
|
||||
}
|
||||
|
||||
$html3->find('div#hrr-link', 0)->outertext = '';
|
||||
$text = $html3->innertext;
|
||||
$text = strip_tags($text, '<h1><span><h2><p><b><a><blockquote><img><em><ul><ol>');
|
||||
return $text;
|
||||
}
|
||||
$html = $this->getSimpleHTMLDOM('http://feeds.feedburner.com/Frandroid?format=xml') or $this->returnError('Could not request Frandroid.', 404);
|
||||
$limit = 0;
|
||||
|
||||
foreach ($html->find('item') as $element) {
|
||||
if ($limit < 5) {
|
||||
$item = new \Item();
|
||||
$item->title = FrandroidStripCDATA($element->find('title', 0)->innertext);
|
||||
$item->uri = FrandroidStripCDATA($element->find('guid', 0)->plaintext);
|
||||
$item->timestamp = strtotime($element->find('pubDate', 0)->plaintext);
|
||||
$item->content = FrandroidExtractContent($item->uri);
|
||||
$this->items[] = $item;
|
||||
$limit++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return 'Frandroid';
|
||||
}
|
||||
|
||||
public function getURI()
|
||||
{
|
||||
return 'http://www.frandroid.com/';
|
||||
}
|
||||
|
||||
public function getCacheDuration()
|
||||
{
|
||||
return 300; // 5min
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue