From 22f0017dc73c681b8a6071ae0080b75401b1b9d6 Mon Sep 17 00:00:00 2001 From: Kevin Lagaisse Date: Mon, 18 May 2015 12:01:13 +0200 Subject: [PATCH] Create CpasbienBridge.php --- bridges/CpasbienBridge.php | 64 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 bridges/CpasbienBridge.php diff --git a/bridges/CpasbienBridge.php b/bridges/CpasbienBridge.php new file mode 100644 index 00000000..d2d1980b --- /dev/null +++ b/bridges/CpasbienBridge.php @@ -0,0 +1,64 @@ +request = str_replace(" ","-",trim($param['q'])); + $html = file_get_html('http://www.cpasbien.pw/recherche/'.urlencode($this->request).'.html') or $this->returnError('No results for this query.', 404); + } + else { + $this->returnError('You must specify a keyword (?q=...).', 400); + } + + foreach ($html->find('#gauche',0)->find('div') as $episode) { + if ($episode->getAttribute('class')=='ligne0' || $episode->getAttribute('class')=='ligne1') + { + $htmlepisode=file_get_html($episode->find('a', 0)->getAttribute('href')); + + $item = new \Item(); + $item->name = $episode->find('a', 0)->text(); + $item->title = $episode->find('a', 0)->text(); + $element=$htmlepisode->find('#textefiche', 0)->find('p',1); + if (isset($element)) { + $item->content = $element->text(); + } + else { + $item->content = $htmlepisode->find('#textefiche', 0)->find('p',0)->text(); + } + + $item->id = $episode->find('a', 0)->getAttribute('href'); + $item->uri = $this->getURI() . $htmlepisode->find('#telecharger',0)->getAttribute('href'); + $this->items[] = $item; + } + } + + + } + + + public function getName(){ + return (!empty($this->request) ? $this->request .' - ' : '') .'Cpasbien Bridge'; + } + + public function getURI(){ + return 'http://www.cpasbien.pw'; + } + + public function getCacheDuration(){ + return 60*60*24; // 24 hours + } +}