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