From 57c8806954c570609db082a061b7b4d135cfe26f Mon Sep 17 00:00:00 2001 From: Dag Date: Tue, 12 Apr 2022 23:37:54 +0200 Subject: [PATCH] [ParuVenduImmo] fix: try to repair broken css selectors (#2641) * [ParuVenduImmo] fix: try to repair broken css selectors Needs more work. --- bridges/ParuVenduImmoBridge.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/bridges/ParuVenduImmoBridge.php b/bridges/ParuVenduImmoBridge.php index 3df64b38..e7a0c02e 100644 --- a/bridges/ParuVenduImmoBridge.php +++ b/bridges/ParuVenduImmoBridge.php @@ -28,7 +28,9 @@ class ParuVenduImmoBridge extends BridgeAbstract { public function collectData(){ $html = getSimpleHTMLDOM($this->getURI()); - foreach($html->find('div.annonce a') as $element) { + $elements = $html->find('#bloc_liste > div.ergov3-annonce a'); + + foreach($elements as $element) { if(!$element->title) { continue; @@ -41,10 +43,19 @@ class ParuVenduImmoBridge extends BridgeAbstract { } } - $desc = $element->find('span.desc')[0]->innertext; - $desc = str_replace("voir l'annonce", '', $desc); + $description = $element->find('p', 0); + if ($description) { + $desc = str_replace("voir l'annonce", '', $description->innertext); + } else { + $desc = ''; + } - $price = $element->find('span.price')[0]->innertext; + $priceElement = $element->find('div.ergov3-priceannonce', 0); + if ($priceElement) { + $price = $priceElement->innertext; + } else { + $price = ''; + } list($href) = explode('#', $element->href);