2015-02-01 17:03:39 +03:00
|
|
|
<?php
|
2017-02-11 18:16:56 +03:00
|
|
|
class ParuVenduImmoBridge extends BridgeAbstract {
|
|
|
|
|
|
|
|
const MAINTAINER = 'polo2ro';
|
|
|
|
const NAME = 'Paru Vendu Immobilier';
|
2019-10-16 22:34:28 +03:00
|
|
|
const URI = 'https://www.paruvendu.fr';
|
2016-09-25 18:04:28 +03:00
|
|
|
const CACHE_TIMEOUT = 10800; // 3h
|
2017-02-11 18:16:56 +03:00
|
|
|
const DESCRIPTION = 'Returns the ads from the first page of search result.';
|
|
|
|
|
|
|
|
const PARAMETERS = array( 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'
|
|
|
|
)
|
|
|
|
));
|
|
|
|
|
|
|
|
public function collectData(){
|
|
|
|
$html = getSimpleHTMLDOM($this->getURI())
|
|
|
|
or returnServerError('Could not request paruvendu.');
|
|
|
|
|
2017-07-29 20:28:00 +03:00
|
|
|
foreach($html->find('div.annonce a') as $element) {
|
2017-02-11 18:16:56 +03:00
|
|
|
|
2017-07-29 20:28:00 +03:00
|
|
|
if(!$element->title) {
|
2017-02-11 18:16:56 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
$img = '';
|
2017-07-29 20:28:00 +03:00
|
|
|
foreach($element->find('span.img img') as $img) {
|
|
|
|
if($img->original) {
|
2017-02-11 18:16:56 +03:00
|
|
|
$img = '<img src="' . $img->original . '" />';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$desc = $element->find('span.desc')[0]->innertext;
|
|
|
|
$desc = str_replace("voir l'annonce", '', $desc);
|
|
|
|
|
|
|
|
$price = $element->find('span.price')[0]->innertext;
|
|
|
|
|
|
|
|
list($href) = explode('#', $element->href);
|
|
|
|
|
|
|
|
$item = array();
|
|
|
|
$item['uri'] = self::URI . $href;
|
|
|
|
$item['title'] = $element->title;
|
|
|
|
$item['content'] = $img . $desc . $price;
|
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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';
|
|
|
|
$link = self::URI
|
|
|
|
. '/immobilier/annonceimmofo/liste/listeAnnonces?tt=1'
|
|
|
|
. $appartment
|
|
|
|
. $maison;
|
|
|
|
|
2017-07-29 20:28:00 +03:00
|
|
|
if($this->getInput('minarea')) {
|
2017-02-11 18:16:56 +03:00
|
|
|
$link .= '&sur0=' . urlencode($this->getInput('minarea'));
|
|
|
|
}
|
|
|
|
|
2017-07-29 20:28:00 +03:00
|
|
|
if($this->getInput('maxprice')) {
|
2017-02-11 18:16:56 +03:00
|
|
|
$link .= '&px1=' . urlencode($this->getInput('maxprice'));
|
|
|
|
}
|
|
|
|
|
2017-07-29 20:28:00 +03:00
|
|
|
if($this->getInput('pa')) {
|
2017-02-11 18:16:56 +03:00
|
|
|
$link .= '&pa=' . urlencode($this->getInput('pa'));
|
|
|
|
}
|
|
|
|
|
2017-07-29 20:28:00 +03:00
|
|
|
if($this->getInput('lo')) {
|
2017-02-11 18:16:56 +03:00
|
|
|
$link .= '&lo=' . urlencode($this->getInput('lo'));
|
|
|
|
}
|
|
|
|
return $link;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getName(){
|
2017-07-29 20:28:00 +03:00
|
|
|
if(!is_null($this->getInput('minarea'))) {
|
2017-02-15 00:20:55 +03:00
|
|
|
$request = '';
|
|
|
|
$minarea = $this->getInput('minarea');
|
2017-07-29 20:28:00 +03:00
|
|
|
if(!empty($minarea)) {
|
2017-02-15 00:20:55 +03:00
|
|
|
$request .= ' ' . $minarea . ' m2';
|
|
|
|
}
|
|
|
|
$location = $this->getInput('lo');
|
2017-07-29 20:28:00 +03:00
|
|
|
if(!empty($location)) {
|
2017-02-15 00:20:55 +03:00
|
|
|
$request .= ' In: ' . $location;
|
|
|
|
}
|
|
|
|
return 'Paru Vendu Immobilier' . $request;
|
2017-02-11 18:16:56 +03:00
|
|
|
}
|
2017-02-15 00:20:55 +03:00
|
|
|
|
|
|
|
return parent::getName();
|
2017-02-11 18:16:56 +03:00
|
|
|
}
|
2015-02-01 17:03:39 +03:00
|
|
|
}
|