From 4f59e2441c8bf0138081e6db944b77af4e2a43fa Mon Sep 17 00:00:00 2001 From: Astalaseven Date: Mon, 16 Dec 2013 09:07:48 +0100 Subject: [PATCH 1/4] [new] Bridges for DTC and SDZ --- bridges/DansTonChatBridge.php | 42 ++++++++++++++++++++++++++++++++ bridges/OpenClassroomsBridge.php | 39 +++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 bridges/DansTonChatBridge.php create mode 100644 bridges/OpenClassroomsBridge.php diff --git a/bridges/DansTonChatBridge.php b/bridges/DansTonChatBridge.php new file mode 100644 index 0000000..06ad5b2 --- /dev/null +++ b/bridges/DansTonChatBridge.php @@ -0,0 +1,42 @@ +returnError('Could not request DansTonChat.', 404); + + foreach($html->find('div.item') as $element) { + $item = new \Item(); + $item->uri = $element->find('a', 0)->href; + $item->title = 'DansTonChat '.$element->find('a', 1)->plaintext; +<<<<<<< HEAD +======= + //$item->content = $element->find('p.item-content', 0)->innertext; +>>>>>>> d194d02... [new] Bridges for DTC and SDZ + $item->content = $element->find('a', 0)->innertext; + $this->items[] = $item; + } + } + + public function getName(){ + return 'DansTonChat'; + } + + public function getURI(){ + return 'http://danstonchat.com'; + } + + public function getCacheDuration(){ + return 21600; // 6 hours + } +} diff --git a/bridges/OpenClassroomsBridge.php b/bridges/OpenClassroomsBridge.php new file mode 100644 index 0000000..d2d3c4a --- /dev/null +++ b/bridges/OpenClassroomsBridge.php @@ -0,0 +1,39 @@ +returnError('Could not request OpenClassrooms.', 404); + + foreach($html->find('li.col6') as $element) { + $item = new \Item(); + $item->uri = 'http://fr.openclassrooms.com'.$element->find('a', 0)->href; + $item->title = $element->find('div.courses-content strong', 0)->innertext; + $item->content = $element->find('span.course-tags', 0)->innertext; + $this->items[] = $item; + } + } + + public function getName(){ + return 'OpenClassrooms'; + } + + public function getURI(){ + return 'http://fr.openclassrooms.com'; + } + + public function getCacheDuration(){ + return 21600; // 6 hours + } +} From 33cf5a1cd50d88a9fd5c2dc68422a823694370a5 Mon Sep 17 00:00:00 2001 From: Astalaseven Date: Mon, 16 Dec 2013 09:11:33 +0100 Subject: [PATCH 2/4] [enh] Remove old comment --- bridges/DansTonChatBridge.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/bridges/DansTonChatBridge.php b/bridges/DansTonChatBridge.php index 06ad5b2..3bb6e0b 100644 --- a/bridges/DansTonChatBridge.php +++ b/bridges/DansTonChatBridge.php @@ -19,10 +19,6 @@ class DansTonChatBridge extends BridgeAbstract{ $item = new \Item(); $item->uri = $element->find('a', 0)->href; $item->title = 'DansTonChat '.$element->find('a', 1)->plaintext; -<<<<<<< HEAD -======= - //$item->content = $element->find('p.item-content', 0)->innertext; ->>>>>>> d194d02... [new] Bridges for DTC and SDZ $item->content = $element->find('a', 0)->innertext; $this->items[] = $item; } From fb44d4d90df3b2bbd21294dc28ae0df6abea660c Mon Sep 17 00:00:00 2001 From: Astalaseven Date: Mon, 16 Dec 2013 15:29:33 +0100 Subject: [PATCH 3/4] [new] DuckDuckGo Bridge --- bridges/DuckDuckGoBridge.php | 39 ++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 bridges/DuckDuckGoBridge.php diff --git a/bridges/DuckDuckGoBridge.php b/bridges/DuckDuckGoBridge.php new file mode 100644 index 0000000..a194a5c --- /dev/null +++ b/bridges/DuckDuckGoBridge.php @@ -0,0 +1,39 @@ +returnError('Could not request DuckDuckGo.', 404); + + foreach($html->find('div.results_links') as $element) { + $item = new \Item(); + $item->uri = $element->find('a', 0)->href; + $item->title = $element->find('a', 1)->innertext; + $item->content = $element->find('div.snippet', 0)->plaintext; + $this->items[] = $item; + } + } + + public function getName(){ + return 'DuckDuckGo'; + } + + public function getURI(){ + return 'https://duckduckgo.com'; + } + + public function getCacheDuration(){ + return 21600; // 6 hours + } +} From 25185cff4ee3875ddb58f85ed37aeb8f14b607fe Mon Sep 17 00:00:00 2001 From: Astalaseven Date: Mon, 16 Dec 2013 17:51:49 +0100 Subject: [PATCH 4/4] [new] Scmb Bridge --- bridges/ScmbBridge.php | 49 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 bridges/ScmbBridge.php diff --git a/bridges/ScmbBridge.php b/bridges/ScmbBridge.php new file mode 100644 index 0000000..e58088d --- /dev/null +++ b/bridges/ScmbBridge.php @@ -0,0 +1,49 @@ +returnError('Could not request Se Coucher Moins Bete.', 404); + + foreach($html->find('article') as $article) { + $item = new \Item(); + $item->uri = 'http://secouchermoinsbete.fr'.$article->find('p.summary a',0)->href; + $item->title = $article->find('header h1 a',0)->innertext; + + $article->find('span.read-more',0)->outertext=''; // remove text "En savoir plus" from anecdote content + $content = $article->find('p.summary a',0)->innertext; + $content =substr($content,0,strlen($content)-17); // remove superfluous spaces at the end + + // get publication date + $str_date = $article->find('time',0)->datetime; + list($date, $time) = explode(' ', $str_date); + list($y, $m, $d) = explode('-', $date); + list($h, $i) = explode(':', $time); + $timestamp = mktime($h,$i,0,$m,$d,$y); + $item->timestamp = $timestamp; + + + $item->content = $content; + $this->items[] = $item; + } + } + + public function getName(){ + return 'Se Coucher Moins BĂȘte Bridge'; + } + + public function getURI(){ + return 'http://secouchermoinsbete.fr/'; + } + + public function getCacheDuration(){ + return 21600; // 6 hours + } +}