mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-11-25 02:46:15 +03:00
951092eef3
$ composer require --dev friendsofphp/php-cs-fixer $ echo >.php-cs-fixer.dist.php "<?php $finder = PhpCsFixer\Finder::create() ->in(__DIR__); $rules = [ '@PSR12' => true, // '@PSR12:risky' => true, '@PHP74Migration' => true, // '@PHP74Migration:risky' => true, // buggy, duplicates existing comment sometimes 'no_break_comment' => false, 'array_syntax' => true, 'lowercase_static_reference' => true, 'visibility_required' => false, // Too much noise 'binary_operator_spaces' => false, 'heredoc_indentation' => false, 'trailing_comma_in_multiline' => false, ]; $config = new PhpCsFixer\Config(); return $config ->setRules($rules) // ->setRiskyAllowed(true) ->setFinder($finder); " $ vendor/bin/php-cs-fixer --version PHP CS Fixer 3.8.0 BerSzcz against war! by Fabien Potencier and Dariusz Ruminski. PHP runtime: 8.1.7 $ vendor/bin/php-cs-fixer fix $ rm .php-cs-fixer.cache $ vendor/bin/php-cs-fixer fix
115 lines
3.3 KiB
PHP
115 lines
3.3 KiB
PHP
<?php
|
|
|
|
class ParuVenduImmoBridge extends BridgeAbstract
|
|
{
|
|
const MAINTAINER = 'polo2ro';
|
|
const NAME = 'Paru Vendu Immobilier';
|
|
const URI = 'https://www.paruvendu.fr';
|
|
const CACHE_TIMEOUT = 10800; // 3h
|
|
const DESCRIPTION = 'Returns the ads from the first page of search result.';
|
|
|
|
const PARAMETERS = [ [
|
|
'minarea' => [
|
|
'name' => 'Minimal surface m²',
|
|
'type' => 'number'
|
|
],
|
|
'maxprice' => [
|
|
'name' => 'Max price',
|
|
'type' => 'number'
|
|
],
|
|
'pa' => [
|
|
'name' => 'Country code',
|
|
'exampleValue' => 'FR'
|
|
],
|
|
'lo' => [
|
|
'name' => 'department numbers or postal codes, comma-separated'
|
|
]
|
|
]];
|
|
|
|
public function collectData()
|
|
{
|
|
$html = getSimpleHTMLDOM($this->getURI());
|
|
|
|
$elements = $html->find('#bloc_liste > div.ergov3-annonce a');
|
|
|
|
foreach ($elements as $element) {
|
|
if (!$element->title) {
|
|
continue;
|
|
}
|
|
|
|
$img = '';
|
|
foreach ($element->find('span.img img') as $img) {
|
|
if ($img->original) {
|
|
$img = '<img src="' . $img->original . '" />';
|
|
}
|
|
}
|
|
|
|
$description = $element->find('p', 0);
|
|
if ($description) {
|
|
$desc = str_replace("voir l'annonce", '', $description->innertext);
|
|
} else {
|
|
$desc = '';
|
|
}
|
|
|
|
$priceElement = $element->find('div.ergov3-priceannonce', 0);
|
|
if ($priceElement) {
|
|
$price = $priceElement->innertext;
|
|
} else {
|
|
$price = '';
|
|
}
|
|
|
|
[$href] = explode('#', $element->href);
|
|
|
|
$item = [];
|
|
$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;
|
|
|
|
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;
|
|
}
|
|
|
|
public function getName()
|
|
{
|
|
if (!is_null($this->getInput('minarea'))) {
|
|
$request = '';
|
|
$minarea = $this->getInput('minarea');
|
|
if (!empty($minarea)) {
|
|
$request .= ' ' . $minarea . ' m2';
|
|
}
|
|
$location = $this->getInput('lo');
|
|
if (!empty($location)) {
|
|
$request .= ' In: ' . $location;
|
|
}
|
|
return 'Paru Vendu Immobilier' . $request;
|
|
}
|
|
|
|
return parent::getName();
|
|
}
|
|
}
|