2015-02-01 15:03:39 +01:00
|
|
|
<?php
|
|
|
|
class ParuVenduImmoBridge extends BridgeAbstract
|
|
|
|
{
|
2016-08-30 11:23:55 +02:00
|
|
|
const MAINTAINER = "polo2ro";
|
|
|
|
const NAME = "Paru Vendu Immobilier";
|
|
|
|
const URI = "http://www.paruvendu.fr";
|
|
|
|
const DESCRIPTION = "Returns the ads from the first page of search result.";
|
2015-11-05 16:50:18 +01:00
|
|
|
|
|
|
|
|
2016-08-30 11:23:55 +02:00
|
|
|
const PARAMETERS = array( array(
|
2016-08-27 21:03:26 +02:00
|
|
|
'minarea'=>array(
|
2016-08-22 01:25:56 +02:00
|
|
|
'name'=>'Minimal surface m²',
|
|
|
|
'type'=>'number'
|
2016-08-27 21:03:26 +02:00
|
|
|
),
|
|
|
|
'maxprice'=>array(
|
2016-08-22 01:25:56 +02:00
|
|
|
'name'=>'Max price',
|
|
|
|
'type'=>'number'
|
2016-08-27 21:03:26 +02:00
|
|
|
),
|
|
|
|
'pa'=>array(
|
2016-08-22 01:25:56 +02:00
|
|
|
'name'=>'Country code',
|
|
|
|
'exampleValue'=>'FR'
|
2016-08-27 21:03:26 +02:00
|
|
|
),
|
|
|
|
'lo'=>array('name'=>'department numbers or postal codes, comma-separated')
|
|
|
|
));
|
2015-11-05 16:50:18 +01:00
|
|
|
|
2016-08-25 01:24:53 +02:00
|
|
|
public function collectData()
|
2015-02-01 15:03:39 +01:00
|
|
|
{
|
2016-08-29 20:23:36 +02:00
|
|
|
$html = $this->getSimpleHTMLDOM($this->getURI())
|
|
|
|
or $this->returnServerError('Could not request paruvendu.');
|
2015-02-01 15:03:39 +01:00
|
|
|
|
|
|
|
foreach($html->find('div.annonce a') as $element) {
|
2016-07-08 19:06:35 +02:00
|
|
|
|
2015-02-01 18:03:15 +01:00
|
|
|
if (!$element->title) {
|
|
|
|
continue;
|
|
|
|
}
|
2016-07-08 19:06:35 +02:00
|
|
|
|
2015-02-01 15:03:39 +01:00
|
|
|
$img ='';
|
|
|
|
foreach($element->find('span.img img') as $img) {
|
|
|
|
if ($img->original) {
|
|
|
|
$img = '<img src="'.$img->original.'" />';
|
|
|
|
}
|
|
|
|
}
|
2016-07-08 19:06:35 +02:00
|
|
|
|
2015-02-01 15:03:39 +01:00
|
|
|
$desc = $element->find('span.desc')[0]->innertext;
|
|
|
|
$desc = str_replace("voir l'annonce", '', $desc);
|
2016-07-08 19:06:35 +02:00
|
|
|
|
2015-02-01 15:03:39 +01:00
|
|
|
$price = $element->find('span.price')[0]->innertext;
|
|
|
|
|
2015-10-23 16:38:37 +02:00
|
|
|
list($href) = explode('#', $element->href);
|
2016-07-08 19:06:35 +02:00
|
|
|
|
2016-08-22 18:55:59 +02:00
|
|
|
$item = array();
|
2016-08-30 11:23:55 +02:00
|
|
|
$item['uri'] = self::URI.$href;
|
2016-08-22 18:55:59 +02:00
|
|
|
$item['title'] = $element->title;
|
|
|
|
$item['content'] = $img.$desc.$price;
|
2015-02-01 15:03:39 +01:00
|
|
|
$this->items[] = $item;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-29 20:23:36 +02:00
|
|
|
public function getURI(){
|
|
|
|
$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';
|
2016-08-30 11:23:55 +02:00
|
|
|
$link = self::URI.'/immobilier/annonceimmofo/liste/listeAnnonces?tt=1'.$appartment.$maison;
|
2016-08-29 20:23:36 +02:00
|
|
|
|
|
|
|
if ($this->getInput('minarea')) {
|
|
|
|
$link .= '&sur0='.urlencode($this->getInput('minarea'));
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->getInput('maxprice')) {
|
|
|
|
$link .= '&px1='.urlencode($this->getInput('maxprice'));
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->getInput('pa')) {
|
|
|
|
$link .= '&pa='.urlencode($this->getInput('pa'));
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->getInput('lo')) {
|
|
|
|
$link .= '&lo='.urlencode($this->getInput('lo'));
|
|
|
|
}
|
|
|
|
return $link;
|
|
|
|
}
|
|
|
|
|
2015-02-01 15:03:39 +01:00
|
|
|
public function getName(){
|
2016-08-27 15:41:42 +02:00
|
|
|
$request='';
|
2016-08-29 20:23:36 +02:00
|
|
|
$minarea=$this->getInput('minarea');
|
|
|
|
if(!empty($minarea)){
|
|
|
|
$request .= ' '.$minarea.' m2';
|
2016-08-27 15:41:42 +02:00
|
|
|
}
|
2016-08-29 20:23:36 +02:00
|
|
|
$location=$this->getInput('lo');
|
|
|
|
if(!empty($location)){
|
|
|
|
$request .= ' In: '.$location;
|
2016-08-27 15:41:42 +02:00
|
|
|
}
|
|
|
|
return 'Paru Vendu Immobilier'.$request;
|
2015-02-01 15:03:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getCacheDuration(){
|
2015-02-01 15:04:59 +01:00
|
|
|
return 10800; // 3 hours
|
2015-02-01 15:03:39 +01:00
|
|
|
}
|
|
|
|
}
|