From 7dd1a7dcccbb074eea70363b83ade6ff2efdef53 Mon Sep 17 00:00:00 2001 From: sal0max Date: Mon, 5 Jul 2021 22:26:08 +0200 Subject: [PATCH] [AmazonPriceTrackerBridge] Fix bridge (#2194) --- bridges/AmazonPriceTrackerBridge.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/bridges/AmazonPriceTrackerBridge.php b/bridges/AmazonPriceTrackerBridge.php index 129ed57c..1d8959a2 100644 --- a/bridges/AmazonPriceTrackerBridge.php +++ b/bridges/AmazonPriceTrackerBridge.php @@ -1,7 +1,7 @@ find('span.offer-price', 0) ?: $html->find('.a-color-price', 0); + $priceString = $priceDiv->plaintext; - preg_match('/^\s*([A-Z]{3}|£|\$)\s?([\d.,]+)\s*$/', $priceDiv->plaintext, $matches); + preg_match('/[\d.,]+/', $priceString, $matches); - if (count($matches) === 3) { + $price = $matches[0]; + $currency = trim(str_replace($price, '', $priceString)); + + if ($price != null && $currency != null) { return array( - 'price' => $matches[2], - 'currency' => $matches[1], + 'price' => $price, + 'currency' => $currency, 'shipping' => '0' ); }