From c44c569aa5d1ce6b6bd9ffde46fadee330ca2107 Mon Sep 17 00:00:00 2001 From: Paul de Rosanbo Date: Sun, 1 Feb 2015 15:03:39 +0100 Subject: [PATCH 1/6] Add paru vendu immo bridge --- bridges/ParuVenduImmoBridge.php | 77 +++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 bridges/ParuVenduImmoBridge.php diff --git a/bridges/ParuVenduImmoBridge.php b/bridges/ParuVenduImmoBridge.php new file mode 100644 index 0000000..cbb420e --- /dev/null +++ b/bridges/ParuVenduImmoBridge.php @@ -0,0 +1,77 @@ +getURI().'/immobilier/annonceimmofo/liste/listeAnnonces?tt=1&tbMai=1&tbVil=1&tbCha=1&tbPro=1&tbHot=1&tbMou=1&tbFer=1'; + + if (isset($param['minarea'])) { + $link .= '&sur0='.urlencode($param['minarea']); + } + + if (isset($param['maxprice'])) { + $link .= '&px1='.urlencode($param['maxprice']); + } + + if (isset($param['pa'])) { + $link .= '&pa='.urlencode($param['pa']); + } + + if (isset($param['lo'])) { + $link .= '&lo='.urlencode($param['lo']); + } + + $html = file_get_html($link) or $this->returnError('Could not request paruvendu.', 404); + + + foreach($html->find('div.annonce a') as $element) { + + $img =''; + foreach($element->find('span.img img') as $img) { + if ($img->original) { + $img = ''; + } + } + + $desc = $element->find('span.desc')[0]->innertext; + $desc = str_replace("voir l'annonce", '', $desc); + + $price = $element->find('span.price')[0]->innertext; + + $item = new \Item(); + $item->uri = $this->getURI().$element->href; + $item->title = $element->title; + $item->content = $img.$desc.$price; + $this->items[] = $item; + + } + } + + public function getName(){ + return 'ParuVenduImmo'; + } + + public function getURI(){ + return 'http://www.paruvendu.fr'; + } + + public function getCacheDuration(){ + return 0; + return 3600; // 1 hour + } +} From e1b5c9cda3196e67faf275da019e2b1cbffbcf54 Mon Sep 17 00:00:00 2001 From: Paul de Rosanbo Date: Sun, 1 Feb 2015 15:04:59 +0100 Subject: [PATCH 2/6] Set cache duration to 3 hours --- bridges/ParuVenduImmoBridge.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bridges/ParuVenduImmoBridge.php b/bridges/ParuVenduImmoBridge.php index cbb420e..303a090 100644 --- a/bridges/ParuVenduImmoBridge.php +++ b/bridges/ParuVenduImmoBridge.php @@ -71,7 +71,6 @@ class ParuVenduImmoBridge extends BridgeAbstract } public function getCacheDuration(){ - return 0; - return 3600; // 1 hour + return 10800; // 3 hours } } From 9cd174ceab49a79a5b11055c0e537bf33c360bcd Mon Sep 17 00:00:00 2001 From: Paul de Rosanbo Date: Sun, 1 Feb 2015 15:15:30 +0100 Subject: [PATCH 3/6] Set name --- bridges/ParuVenduImmoBridge.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bridges/ParuVenduImmoBridge.php b/bridges/ParuVenduImmoBridge.php index 303a090..cf3c3bb 100644 --- a/bridges/ParuVenduImmoBridge.php +++ b/bridges/ParuVenduImmoBridge.php @@ -5,7 +5,7 @@ * Returns the N most recent documents, sorting by date (most recent first). * 2014-05-25 * -* @name ParuVenduImmoBridge +* @name Paru Vendu Immobilier * @homepage http://www.paruvendu.fr/immobilier/ * @description Returns the N most recent documents. * @maintainer polo2ro @@ -13,6 +13,7 @@ */ class ParuVenduImmoBridge extends BridgeAbstract { + private $request = ''; public function collectData(array $param) { @@ -21,6 +22,7 @@ class ParuVenduImmoBridge extends BridgeAbstract $link = $this->getURI().'/immobilier/annonceimmofo/liste/listeAnnonces?tt=1&tbMai=1&tbVil=1&tbCha=1&tbPro=1&tbHot=1&tbMou=1&tbFer=1'; if (isset($param['minarea'])) { + $this->request .= ' '.$param['minarea'].' m2'; $link .= '&sur0='.urlencode($param['minarea']); } @@ -33,6 +35,7 @@ class ParuVenduImmoBridge extends BridgeAbstract } if (isset($param['lo'])) { + $this->request .= ' In: '.$param['lo']; $link .= '&lo='.urlencode($param['lo']); } @@ -63,7 +66,7 @@ class ParuVenduImmoBridge extends BridgeAbstract } public function getName(){ - return 'ParuVenduImmo'; + return 'Paru Vendu Immobilier'.$this->request; } public function getURI(){ From 4b04a77b00d2c7ebe47821a7a76374745b7d7bc3 Mon Sep 17 00:00:00 2001 From: Paul de Rosanbo Date: Sun, 1 Feb 2015 18:03:15 +0100 Subject: [PATCH 4/6] Remove empty entries --- bridges/ParuVenduImmoBridge.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bridges/ParuVenduImmoBridge.php b/bridges/ParuVenduImmoBridge.php index cf3c3bb..717b2c4 100644 --- a/bridges/ParuVenduImmoBridge.php +++ b/bridges/ParuVenduImmoBridge.php @@ -9,7 +9,7 @@ * @homepage http://www.paruvendu.fr/immobilier/ * @description Returns the N most recent documents. * @maintainer polo2ro -* @use1(minarea="Min area",maxprice="Max price",pa="Country code",lo="department number") +* @use1(minarea="Min area",maxprice="Max price",pa="Country code",lo="department numbers, comma-separated") */ class ParuVenduImmoBridge extends BridgeAbstract { @@ -44,6 +44,10 @@ class ParuVenduImmoBridge extends BridgeAbstract foreach($html->find('div.annonce a') as $element) { + if (!$element->title) { + continue; + } + $img =''; foreach($element->find('span.img img') as $img) { if ($img->original) { From 1a673766ecdc1f64b0592125c109b803d9caab49 Mon Sep 17 00:00:00 2001 From: Paul de Rosanbo Date: Sun, 1 Feb 2015 19:20:13 +0100 Subject: [PATCH 5/6] Add flat --- bridges/ParuVenduImmoBridge.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bridges/ParuVenduImmoBridge.php b/bridges/ParuVenduImmoBridge.php index 717b2c4..795d328 100644 --- a/bridges/ParuVenduImmoBridge.php +++ b/bridges/ParuVenduImmoBridge.php @@ -19,7 +19,9 @@ class ParuVenduImmoBridge extends BridgeAbstract { $html = ''; $num = 20; - $link = $this->getURI().'/immobilier/annonceimmofo/liste/listeAnnonces?tt=1&tbMai=1&tbVil=1&tbCha=1&tbPro=1&tbHot=1&tbMou=1&tbFer=1'; + $appartment = '&tbApp=1&tbDup=1&tbChb=1&tbLof=1&tbAtl=1&tbPla=1'; + $maison = '&tbMai=1&tbVil=1&tbCha=1&tbPro=1&tbHot=1&tbMou=1&tbFer=1'; + $link = $this->getURI().'/immobilier/annonceimmofo/liste/listeAnnonces?tt=1'.$appartment.$maison; if (isset($param['minarea'])) { $this->request .= ' '.$param['minarea'].' m2'; From 9171be9c504d03ba9213f4f20f9a1b252adbb6f2 Mon Sep 17 00:00:00 2001 From: Paul de Rosanbo Date: Mon, 2 Feb 2015 22:37:18 +0100 Subject: [PATCH 6/6] More descriptions --- bridges/ParuVenduImmoBridge.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/bridges/ParuVenduImmoBridge.php b/bridges/ParuVenduImmoBridge.php index 795d328..88068f9 100644 --- a/bridges/ParuVenduImmoBridge.php +++ b/bridges/ParuVenduImmoBridge.php @@ -2,14 +2,13 @@ /** * RssBridge Paru Vendu Immo * Retrieve lastest documents from http://www.paruvendu.fr/immobilier/. -* Returns the N most recent documents, sorting by date (most recent first). -* 2014-05-25 * * @name Paru Vendu Immobilier * @homepage http://www.paruvendu.fr/immobilier/ -* @description Returns the N most recent documents. +* @description Returns the ads from the first page of search result. * @maintainer polo2ro -* @use1(minarea="Min area",maxprice="Max price",pa="Country code",lo="department numbers, comma-separated") +* @update 2015-02-02 +* @use1(minarea="Min surface m²",maxprice="Max price",pa="Country code (ex: FR)",lo="department numbers or postal codes, comma-separated") */ class ParuVenduImmoBridge extends BridgeAbstract {