From 46a5f717a16a1f60fc5e2291c5c37526e7c9ae8c Mon Sep 17 00:00:00 2001 From: pit-fgfjiudghdf Date: Mon, 10 Mar 2014 19:22:12 +0100 Subject: [PATCH] Create RaymondBridge.php --- bridges/RaymondBridge.php | 51 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 bridges/RaymondBridge.php diff --git a/bridges/RaymondBridge.php b/bridges/RaymondBridge.php new file mode 100644 index 00000000..40d22e62 --- /dev/null +++ b/bridges/RaymondBridge.php @@ -0,0 +1,51 @@ +', '', $string); + return $string; + } + function raymondExtractContent($url) { + $html2 = file_get_html($url); + $text = $html2->find('div.entry-content', 0)->innertext; + $text = str_replace('', '', $text); + $text = str_replace('', '', $text); + $text = str_replace('script*.script', '', $text); + $text = str_replace('‌', '', $text); + $text = str_replace('<', '<', $text); + return $text; + } + $html = file_get_html('http://www.raymond.cc/blog/feed') or $this->returnError('Could not request raymond.', 404); + $limit = 0; + foreach($html->find('item') as $element) { + if($limit < 20) { + $item = new \Item(); + $item->title = raymondStripCDATA($element->find('title', 0)->innertext); + $item->uri = raymondStripCDATA($element->find('guid', 0)->plaintext); + $item->timestamp = strtotime($element->find('pubDate', 0)->plaintext); + $item->content = raymondExtractContent($item->uri); + $this->items[] = $item; + $limit++; + } + } + + } + public function getName(){ + return 'raymond'; + } + public function getURI(){ + return 'http://www.raymond.cc/blog'; + } + public function getCacheDuration(){ + return 3600; // 1 hour + } +}