From bf2303ead8b6c8aa01a3e1c58ddd27cbc4fc2d71 Mon Sep 17 00:00:00 2001 From: Mitsukarenai Date: Wed, 23 Jul 2014 13:11:55 +0200 Subject: [PATCH] [ pull request #86 ] --- bridges/ABCTabsBridge.php | 44 ++++++++++++++++++++++++++++++++++ bridges/MondeDiploBridge.php | 46 +++++++++++++++++++++++------------- bridges/ScoopItBridge.php | 21 +++++++++------- bridges/WhydBridge.php | 3 ++- 4 files changed, 89 insertions(+), 25 deletions(-) create mode 100644 bridges/ABCTabsBridge.php diff --git a/bridges/ABCTabsBridge.php b/bridges/ABCTabsBridge.php new file mode 100644 index 0000000..f0973b6 --- /dev/null +++ b/bridges/ABCTabsBridge.php @@ -0,0 +1,44 @@ +returnError('No results for this query.', 404); + $table = $html->find('table#myTable', 0)->children(1); + + foreach ($table->find('tr') as $tab) + { + $item = new \Item(); + $item->name = $tab->find('td', 1)->plaintext . ' - ' . $tab->find('td', 2)->plaintext; + $item->title = $tab->find('td', 1)->plaintext . ' - ' . $tab->find('td', 2)->plaintext; + $item->content = 'Le ' . $tab->find('td', 0)->plaintext . '
Par: ' . $tab->find('td', 5)->plaintext . '
Type: ' . $tab->find('td', 3)->plaintext; + $item->id = 'http://www.abc-tabs.com' . $tab->find('td', 2)->find('a', 0)->getAttribute('href'); + $item->uri = 'http://www.abc-tabs.com' . $tab->find('td', 2)->find('a', 0)->getAttribute('href'); + $this->items[] = $item; + } + } + public function getName(){ + return 'ABC Tabs Bridge'; + } + + public function getURI(){ + return 'http://www.abc-tabs.com/'; + } + + public function getCacheDuration(){ + return 3600; // 1 hour + } +} diff --git a/bridges/MondeDiploBridge.php b/bridges/MondeDiploBridge.php index f6abe7c..65a155b 100644 --- a/bridges/MondeDiploBridge.php +++ b/bridges/MondeDiploBridge.php @@ -10,29 +10,42 @@ * @description Returns most recent results from MondeDiplo. * @maintainer Pitchoule */ + class MondeDiploBridge extends BridgeAbstract{ public function collectData(array $param){ $link = 'http://www.monde-diplomatique.fr'; - + $html = file_get_html($link) or $this->returnError('Could not request MondeDiplo. for : ' . $link , 404); - - foreach($html->find('div[class=grid_10 alpha omega laune]') as $element) { - $item = new Item(); - $item->uri = 'http://www.monde-diplomatique.fr'.$element->find('a', 0)->href; - $NumArticle = explode("/", $element->find('a', 0)->href); - $item->title = $element->find('h3', 0)->plaintext; - $item->content = $element->find('div[class=crayon article-intro-'.$NumArticle[4].' intro]', 0)->plaintext; - $this->items[] = $item; - } - - foreach($html->find('div.titraille') as $element) { - $item = new Item(); + + foreach($html->find('div.laune') as $element) { + $item = new Item(); + $item->uri = 'http://www.monde-diplomatique.fr'.$element->find('a', 0)->href; + $item->title = $element->find('h3', 0)->plaintext; + $item->content = $element->find('div.dates_auteurs', 0)->plaintext. '
' .strstr($element->find('div', 0)->plaintext, $element->find('div.dates_auteurs', 0)->plaintext, true); + $this->items[] = $item; + } + + $liste = $html->find('div.listes', 0); // First list + foreach ($liste->find('li') as $e) { + + $item = new Item(); + $item->uri = 'http://www.monde-diplomatique.fr' . $e->find('a', 0)->href; + $item->title = $e->find('a', 0)->plaintext; + $item->content = $e->find('div.dates_auteurs', 0)->plaintext; + $this->items[] = $item; + } + + foreach($html->find('div.liste ul li') as $element) { + if ($element->getAttribute('class') != 'intrapub') { + $item = new Item(); $item->uri = 'http://www.monde-diplomatique.fr'.$element->find('a', 0)->href; $item->title = $element->find('h3', 0)->plaintext; - $item->content = $element->find('div.dates_auteurs', 0)->plaintext; + $item->content = $element->find('div.dates_auteurs', 0)->plaintext . '
' . $element->find('div.intro', 0)->plaintext; $this->items[] = $item; - } + } + } + } public function getName(){ @@ -47,4 +60,5 @@ class MondeDiploBridge extends BridgeAbstract{ return 21600; // 6 hours } } - + + diff --git a/bridges/ScoopItBridge.php b/bridges/ScoopItBridge.php index 7e85f5b..d8d7127 100644 --- a/bridges/ScoopItBridge.php +++ b/bridges/ScoopItBridge.php @@ -15,17 +15,21 @@ class ScoopItBridge extends BridgeAbstract{ public function collectData(array $param){ $html = ''; - $this->request = $param['u']; - $link = 'http://scoop.it/search?q=' .urlencode($this->request); - - $html = file_get_html($link) or $this->returnError('Could not request ScoopIt. for : ' . $link , 404); - - foreach($html->find('div.post-view') as $element) { + if ($param['u'] != '') { + $this->request = $param['u']; + $link = 'http://scoop.it/search?q=' .urlencode($this->request); + + $html = file_get_html($link) or $this->returnError('Could not request ScoopIt. for : ' . $link , 404); + + foreach($html->find('div.post-view') as $element) { $item = new Item(); $item->uri = $element->find('a', 0)->href; - $item->title = $element->find('div.tCustomization_post_title',0)->plaintext; - $item->content = $element->find('div.tCustomization_post_description', 0)->plaintext; + $item->title = preg_replace('~[[:cntrl:]]~', '', $element->find('div.tCustomization_post_title',0)->plaintext); + $item->content = preg_replace('~[[:cntrl:]]~', '', $element->find('div.tCustomization_post_description', 0)->plaintext); $this->items[] = $item; + } + } else { + $this->returnError('You must specify a keyword', 404); } } @@ -41,3 +45,4 @@ class ScoopItBridge extends BridgeAbstract{ return 21600; // 6 hours } } + diff --git a/bridges/WhydBridge.php b/bridges/WhydBridge.php index 2e25873..9bac7a0 100644 --- a/bridges/WhydBridge.php +++ b/bridges/WhydBridge.php @@ -8,7 +8,7 @@ * @description Returns 10 newest music from user profile * @maintainer kranack * @update 2014-07-18 -* @use1(u="username") +* @use1(u="username/id") * */ class WhydBridge extends BridgeAbstract{ @@ -63,3 +63,4 @@ class WhydBridge extends BridgeAbstract{ } } +