Add CoinDesk, update Maliki
This commit is contained in:
parent
e816b2aa80
commit
237886feb6
2 changed files with 81 additions and 7 deletions
56
bridges/CoinDeskBridge.php
Normal file
56
bridges/CoinDeskBridge.php
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* RssBridgeCoinDesk
|
||||||
|
* Returns the 5 newest posts from coindesk.com (full text)
|
||||||
|
*
|
||||||
|
* @name CoinDesk
|
||||||
|
* @homepage http://www.coindesk.com/
|
||||||
|
* @description Returns the 5 newest posts from CoinDesk (full text)
|
||||||
|
* @maintainer mitsukarenai
|
||||||
|
* @update 2014-05-30
|
||||||
|
*/
|
||||||
|
class CoinDeskBridge extends BridgeAbstract{
|
||||||
|
|
||||||
|
public function collectData(array $param){
|
||||||
|
|
||||||
|
function CoinDeskStripCDATA($string) {
|
||||||
|
$string = str_replace('<![CDATA[', '', $string);
|
||||||
|
$string = str_replace(']]>', '', $string);
|
||||||
|
return $string;
|
||||||
|
}
|
||||||
|
function CoinDeskExtractContent($url) {
|
||||||
|
$html2 = file_get_html($url);
|
||||||
|
$text = $html2->find('div.single-content', 0)->innertext;
|
||||||
|
$text = strip_tags($text, '<p><a><img>');
|
||||||
|
return $text;
|
||||||
|
}
|
||||||
|
$html = file_get_html('http://www.coindesk.com/feed/atom/') or $this->returnError('Could not request CoinDesk.', 404);
|
||||||
|
$limit = 0;
|
||||||
|
|
||||||
|
foreach($html->find('entry') as $element) {
|
||||||
|
if($limit < 5) {
|
||||||
|
$item = new \Item();
|
||||||
|
$item->title = CoinDeskStripCDATA($element->find('title', 0)->innertext);
|
||||||
|
$item->author = $element->find('author', 0)->plaintext;
|
||||||
|
$item->uri = $element->find('link', 0)->href;
|
||||||
|
$item->timestamp = strtotime($element->find('published', 0)->plaintext);
|
||||||
|
$item->content = CoinDeskExtractContent($item->uri);
|
||||||
|
$this->items[] = $item;
|
||||||
|
$limit++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(){
|
||||||
|
return 'CoinDesk';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getURI(){
|
||||||
|
return 'http://www.coindesk.com/';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCacheDuration(){
|
||||||
|
return 1800; // 30min
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,27 +1,45 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* RssBridgeMaliki
|
* RssBridgeMaliki
|
||||||
* Returns Maliki's strips from previous weeks
|
* Returns Maliki's newest strips
|
||||||
* 2014-05-25
|
|
||||||
*
|
*
|
||||||
* @name Maliki
|
* @name Maliki
|
||||||
* @homepage http://www.maliki.com/
|
* @homepage http://www.maliki.com/
|
||||||
* @description Returns Maliki's strips from previous weeks
|
* @description Returns Maliki's newest strips
|
||||||
* @maintainer mitsukarenai
|
* @maintainer mitsukarenai
|
||||||
|
* @update 2014-05-30
|
||||||
*/
|
*/
|
||||||
class MalikiBridge extends BridgeAbstract{
|
class MalikiBridge extends BridgeAbstract{
|
||||||
|
|
||||||
public function collectData(array $param){
|
public function collectData(array $param){
|
||||||
$html = file_get_html('http://www.maliki.com/') or $this->returnError('Could not request Maliki.', 404);
|
$html = file_get_html('http://www.maliki.com/') or $this->returnError('Could not request Maliki.', 404);
|
||||||
$count=0;
|
$count=0;
|
||||||
|
$latest=1; $latest_title="";
|
||||||
|
$latest = $html->find('div.conteneur_page a', 1)->href;
|
||||||
|
$latest_title = $html->find('div.conteneur_page img', 0)->title;
|
||||||
|
|
||||||
|
function MalikiExtractContent($url) {
|
||||||
|
$html2 = file_get_html($url);
|
||||||
|
$text = 'http://www.maliki.com/'.$html2->find('img', 0)->src;
|
||||||
|
$text = '<img alt="" src="'.$text.'"/><br>'.$html2->find('div.imageetnews', 0)->plaintext;
|
||||||
|
return $text;
|
||||||
|
}
|
||||||
|
|
||||||
|
$item = new \Item();
|
||||||
|
$item->uri = 'http://www.maliki.com/'.$latest;
|
||||||
|
$item->title = $latest_title;
|
||||||
|
$item->timestamp = time();
|
||||||
|
$item->content = MalikiExtractContent($item->uri);
|
||||||
|
$this->items[] = $item;
|
||||||
|
|
||||||
|
|
||||||
foreach($html->find('div.boite_strip') as $element) {
|
foreach($html->find('div.boite_strip') as $element) {
|
||||||
if(!empty($element->find('a',0)->href) and $count < 20) {
|
if(!empty($element->find('a',0)->href) and $count < 3) {
|
||||||
$item = new \Item();
|
$item = new \Item();
|
||||||
$item->uri = 'http://www.maliki.com/'.$element->find('a',0)->href;
|
$item->uri = 'http://www.maliki.com/'.$element->find('a',0)->href;
|
||||||
$item->thumbnailUri = 'http://www.maliki.com/'.$element->find('img',0)->src;
|
|
||||||
$item->title = $element->find('img',0)->title;
|
$item->title = $element->find('img',0)->title;
|
||||||
$item->timestamp = strtotime(str_replace('/', '-', $element->find('span.stylepetit', 0)->innertext));
|
$item->timestamp = strtotime(str_replace('/', '-', $element->find('span.stylepetit', 0)->innertext));
|
||||||
$item->content = '<a href="' . $item->uri . '"><img src="' . $item->thumbnailUri . '" /></a>';
|
$item->content = MalikiExtractContent($item->uri);
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
$count++;
|
$count++;
|
||||||
}
|
}
|
||||||
|
@ -37,6 +55,6 @@ class MalikiBridge extends BridgeAbstract{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCacheDuration(){
|
public function getCacheDuration(){
|
||||||
return 86400; // 24 hours
|
return 86400*6; // 6 days
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue