bring out scraped unit data
This commit is contained in:
parent
29847b9127
commit
4a49a06fce
@ -207,10 +207,16 @@ class Oda
|
|||||||
|
|
||||||
$name = trim((string) $crawler->filter('h1')->text());
|
$name = trim((string) $crawler->filter('h1')->text());
|
||||||
$price = (float) $crawler->filter('.price')->attr('content');
|
$price = (float) $crawler->filter('.price')->attr('content');
|
||||||
|
$price_unit_string = trim((string) $crawler->filter('.unit-price')->text());
|
||||||
|
## Møkkete datavask på string begynn kr 50,50 per unit
|
||||||
|
$price_unit_string_nocurrency = trim($price_unit_string, 'kr '); // 50,50 per unit
|
||||||
|
$price_unit_string_dotfix = str_replace(',','.', $price_unit_string_nocurrency);# 50.50 per unit
|
||||||
|
$unit_data = explode(' per ',$price_unit_string_dotfix); // 50.50 unit
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'price' => $price,
|
'price' => $price,
|
||||||
|
'unit_type' => $unit_data,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user