[LaCentrale] fix: broken css selectors (#2636)

This commit is contained in:
Dag 2022-04-12 23:34:23 +02:00 committed by GitHub
parent 6021d2ffa6
commit df5c259375
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 17 deletions

View File

@ -1,4 +1,5 @@
<?php <?php
class LaCentraleBridge extends BridgeAbstract { class LaCentraleBridge extends BridgeAbstract {
const MAINTAINER = 'jacknumber'; const MAINTAINER = 'jacknumber';
@ -414,9 +415,9 @@ class LaCentraleBridge extends BridgeAbstract {
)); ));
public function collectData(){ public function collectData(){
// check data
if(!empty($this->getInput('distance')) if(!empty($this->getInput('distance'))
&& is_null($this->getInput('location'))) { && is_null($this->getInput('location'))
) {
returnClientError('You need a place ("CP ou département") to search arround.'); returnClientError('You need a place ("CP ou département") to search arround.');
} }
@ -442,35 +443,31 @@ class LaCentraleBridge extends BridgeAbstract {
'doors' => $this->getInput('doors'), 'doors' => $this->getInput('doors'),
'sortBy' => $this->getInput('sort') 'sortBy' => $this->getInput('sort')
); );
$url = self::URI . 'listing?' . http_build_query($params); $url = sprintf('%slisting?%s', self::URI, http_build_query($params));
$html = getSimpleHTMLDOM($url); $html = getSimpleHTMLDOM($url);
foreach($html->find('.linkAd') as $element) { $elements = $html->find('.adLineContainer');
foreach($elements as $element) {
$item = array(); $item = array();
$item['uri'] = trim(self::URI, '/') . $element->href; $item['uri'] = trim(self::URI, '/') . $element->find('div > a', 0)->href;
$item['title'] = $element->find('.brandModel', 0)->plaintext; $item['title'] = $element->find('.searchCard__makeModel', 0)->plaintext;
$item['sellerType'] = $element->find('.typeSeller', 0)->plaintext; $item['sellerType'] = $element->find('.searchCard__customer', 0)->plaintext;
$item['author'] = $item['sellerType']; $item['author'] = $item['sellerType'];
$item['version'] = $element->find('.version', 0)->plaintext; $item['version'] = $element->find('.searchCard__version', 0)->plaintext;
$item['price'] = $element->find('.fieldPrice', 0)->plaintext; $item['price'] = $element->find('.searchCard__fieldPrice', 0)->plaintext;
$item['year'] = $element->find('.fieldYear', 0)->plaintext; $item['year'] = $element->find('.searchCard__year', 0)->plaintext;
$item['mileage'] = $element->find('.fieldMileage', 0)->plaintext; $item['mileage'] = $element->find('.searchCard__mileage', 0)->plaintext;
$item['departement'] = str_replace(',', '', $element->find('.dptCont', 0)->plaintext); // The image is lazyloaded with ajax
$item['thumbnail'] = $element->find('.imgContent img', 0)->src;
$item['enclosures'] = array($item['thumbnail']);
$item['content'] = ' $item['content'] = '
<img src="' . $item['thumbnail'] . '">
<br>Variation : ' . $item['version'] <br>Variation : ' . $item['version']
. '<br>Prix : ' . $item['price'] . '<br>Prix : ' . $item['price']
. '<br>Année : ' . $item['year'] . '<br>Année : ' . $item['year']
. '<br>Kilométrage : ' . $item['mileage'] . '<br>Kilométrage : ' . $item['mileage']
. '<br>Département : ' . $item['departement']
. '<br>Type de vendeur : ' . $item['sellerType']; . '<br>Type de vendeur : ' . $item['sellerType'];
$this->items[] = $item; $this->items[] = $item;
} }
} }
} }