-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bridges: use BridgeAbstract::getSimpleHTMLDOM
instead of BridgeAbstract::file_get_html Signed-off-by: Pierre Mazière <[email protected]>
- Loading branch information
Pierre Mazière
committed
Aug 19, 2016
1 parent
f43bbda
commit 3c0d13c
Showing
121 changed files
with
1,212 additions
and
396 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
class CoinDeskBridge extends BridgeAbstract{ | ||
|
||
public function loadMetadatas() { | ||
|
||
$this->maintainer = "mitsukarenai"; | ||
$this->name = "CoinDesk"; | ||
$this->uri = "http://www.coindesk.com/"; | ||
$this->description = "Returns the 5 newest posts from CoinDesk (full text)"; | ||
$this->update = "2014-05-30"; | ||
|
||
} | ||
|
||
public function collectData(array $param){ | ||
|
||
function CoinDeskStripCDATA($string) { | ||
$string = str_replace('<![CDATA[', '', $string); | ||
$string = str_replace(']]>', '', $string); | ||
return $string; | ||
} | ||
function CoinDeskExtractContent($url) { | ||
$html2 = $this->getSimpleHTMLDOM($url); | ||
$text = $html2->find('div.single-content', 0)->innertext; | ||
$text = strip_tags($text, '<p><a><img>'); | ||
return $text; | ||
} | ||
$html = $this->getSimpleHTMLDOM('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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.