rss-bridge/bridges/ParuVenduImmoBridge.php

87 lines
2.6 KiB
PHP
Raw Normal View History

2015-02-01 17:03:39 +03:00
<?php
/**
* RssBridge Paru Vendu Immo
* Retrieve lastest documents from http://www.paruvendu.fr/immobilier/.
*
2015-02-01 17:15:30 +03:00
* @name Paru Vendu Immobilier
2015-02-01 17:03:39 +03:00
* @homepage http://www.paruvendu.fr/immobilier/
2015-02-03 00:37:18 +03:00
* @description Returns the ads from the first page of search result.
2015-02-01 17:03:39 +03:00
* @maintainer polo2ro
2015-02-03 00:37:18 +03:00
* @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")
2015-02-01 17:03:39 +03:00
*/
class ParuVenduImmoBridge extends BridgeAbstract
{
2015-02-01 17:15:30 +03:00
private $request = '';
2015-02-01 17:03:39 +03:00
public function collectData(array $param)
{
$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';
$link = $this->getURI().'/immobilier/annonceimmofo/liste/listeAnnonces?tt=1'.$appartment.$maison;
2015-02-01 17:03:39 +03:00
if (isset($param['minarea'])) {
2015-02-01 17:15:30 +03:00
$this->request .= ' '.$param['minarea'].' m2';
2015-02-01 17:03:39 +03:00
$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'])) {
2015-02-01 17:15:30 +03:00
$this->request .= ' In: '.$param['lo'];
2015-02-01 17:03:39 +03:00
$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) {
2015-02-01 20:03:15 +03:00
if (!$element->title) {
continue;
}
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.'" />';
}
}
$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);
2015-02-01 17:03:39 +03:00
$item = new \Item();
$item->uri = $this->getURI().$href;
2015-02-01 17:03:39 +03:00
$item->title = $element->title;
$item->content = $img.$desc.$price;
$this->items[] = $item;
}
}
public function getName(){
2015-02-01 17:15:30 +03:00
return 'Paru Vendu Immobilier'.$this->request;
2015-02-01 17:03:39 +03:00
}
public function getURI(){
return 'http://www.paruvendu.fr';
}
public function getCacheDuration(){
2015-02-01 17:04:59 +03:00
return 10800; // 3 hours
2015-02-01 17:03:39 +03:00
}
}