mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-04-09 16:38:50 +00:00
[AmazonPriceTrackerBridge] Fixes for subscription items (#2205)
This commit is contained in:
parent
cb7f5b057f
commit
9fa782105d
@ -40,6 +40,15 @@ class AmazonPriceTrackerBridge extends BridgeAbstract {
|
|||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
|
const PRICE_SELECTORS = array(
|
||||||
|
'#priceblock_ourprice',
|
||||||
|
'.priceBlockBuyingPriceString',
|
||||||
|
'#newBuyBoxPrice',
|
||||||
|
'#tp_price_block_total_price_ww',
|
||||||
|
'span.offer-price',
|
||||||
|
'.a-color-price',
|
||||||
|
);
|
||||||
|
|
||||||
protected $title;
|
protected $title;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -54,7 +63,7 @@ class AmazonPriceTrackerBridge extends BridgeAbstract {
|
|||||||
*/
|
*/
|
||||||
public function getURI() {
|
public function getURI() {
|
||||||
if (!is_null($this->getInput('asin'))) {
|
if (!is_null($this->getInput('asin'))) {
|
||||||
return $this->getDomainName() . '/dp/' . $this->getInput('asin') . '/';
|
return $this->getDomainName() . '/dp/' . $this->getInput('asin');
|
||||||
}
|
}
|
||||||
return parent::getURI();
|
return parent::getURI();
|
||||||
}
|
}
|
||||||
@ -146,13 +155,25 @@ EOT;
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function scrapePriceGeneric($html) {
|
private function scrapePriceGeneric($html) {
|
||||||
$priceDiv = $html->find('span.offer-price', 0) ?: $html->find('.a-color-price', 0);
|
$priceDiv = null;
|
||||||
|
|
||||||
|
foreach(self::PRICE_SELECTORS as $sel) {
|
||||||
|
$priceDiv = $html->find($sel, 0);
|
||||||
|
if ($priceDiv) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$priceDiv) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$priceString = $priceDiv->plaintext;
|
$priceString = $priceDiv->plaintext;
|
||||||
|
|
||||||
preg_match('/[\d.,]+/', $priceString, $matches);
|
preg_match('/[\d.,]+/', $priceString, $matches);
|
||||||
|
|
||||||
$price = $matches[0];
|
$price = $matches[0];
|
||||||
$currency = trim(str_replace($price, '', $priceString));
|
$currency = trim(str_replace($price, '', $priceString), " \t\n\r\0\x0B\xC2\xA0");
|
||||||
|
|
||||||
if ($price != null && $currency != null) {
|
if ($price != null && $currency != null) {
|
||||||
return array(
|
return array(
|
||||||
@ -180,6 +201,8 @@ EOT;
|
|||||||
'title' => $this->title,
|
'title' => $this->title,
|
||||||
'uri' => $this->getURI(),
|
'uri' => $this->getURI(),
|
||||||
'content' => "$imageTag<br/>Price: {$data['price']} {$data['currency']}",
|
'content' => "$imageTag<br/>Price: {$data['price']} {$data['currency']}",
|
||||||
|
// This is to ensure that feed readers notice the price change
|
||||||
|
'uid' => md5($data['price'])
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($data['shipping'] !== '0') {
|
if ($data['shipping'] !== '0') {
|
||||||
|
Loading…
Reference in New Issue
Block a user