🐛 Corrige le parsing du prix OuestFrance

Fix #23
This commit is contained in:
Clément 2021-05-06 11:04:30 +02:00
parent a9ee66a2d4
commit fc9bbd9e4d

View File

@ -18,9 +18,13 @@ class OuestFrance extends Parser
$crawler = new Crawler($body); $crawler = new Crawler($body);
$parsedHome = new ParsedHome(); $parsedHome = new ParsedHome();
$parsedHome->title = $crawler->filter('h1')->text(); $parsedHome->title = $crawler->filter('h1')->text();
$parsedHome->price = (int)str_replace(' ', '', $crawler->filter('#strongPrix')->text());
$parsedHome->description = $crawler->filter('#blockonDescriptif')->text();
$details = $crawler->filter('#blocCaractAnn > ul > li'); $details = $crawler->filter('#blocCaractAnn > ul > li');
$price = $crawler->filter('#strongPrix');
if (!$price instanceof Crawler) {
$price = $details->eq(0)->filter('strong')->text();
}
$parsedHome->price = (int)str_replace(' ', '', $price->text());
$parsedHome->description = $crawler->filter('#blockonDescriptif')->text();
$parsedHome->surface = (int)str_replace(' ', '', $details->eq(2)->filter('strong')->text()); $parsedHome->surface = (int)str_replace(' ', '', $details->eq(2)->filter('strong')->text());
$parsedHome->garden_surface = (int)str_replace(' ', '', $details->eq(3)->filter('strong')->text()); $parsedHome->garden_surface = (int)str_replace(' ', '', $details->eq(3)->filter('strong')->text());
$parsedHome->rooms = (int)str_replace(' ', '', $details->eq(4)->filter('strong')->text()); $parsedHome->rooms = (int)str_replace(' ', '', $details->eq(4)->filter('strong')->text());