mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-04-24 23:37:18 +00:00
[AmazonPriceTrackerBridge] Fix bridge (#2194)
This commit is contained in:
parent
1f6ad000ce
commit
7dd1a7dccc
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class AmazonPriceTrackerBridge extends BridgeAbstract {
|
class AmazonPriceTrackerBridge extends BridgeAbstract {
|
||||||
const MAINTAINER = 'captn3m0';
|
const MAINTAINER = 'captn3m0, sal0max';
|
||||||
const NAME = 'Amazon Price Tracker';
|
const NAME = 'Amazon Price Tracker';
|
||||||
const URI = 'https://www.amazon.com/';
|
const URI = 'https://www.amazon.com/';
|
||||||
const CACHE_TIMEOUT = 3600; // 1h
|
const CACHE_TIMEOUT = 3600; // 1h
|
||||||
@ -147,13 +147,17 @@ EOT;
|
|||||||
|
|
||||||
private function scrapePriceGeneric($html) {
|
private function scrapePriceGeneric($html) {
|
||||||
$priceDiv = $html->find('span.offer-price', 0) ?: $html->find('.a-color-price', 0);
|
$priceDiv = $html->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(
|
return array(
|
||||||
'price' => $matches[2],
|
'price' => $price,
|
||||||
'currency' => $matches[1],
|
'currency' => $currency,
|
||||||
'shipping' => '0'
|
'shipping' => '0'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user