mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-01-17 14:18:35 +01:00
[PepperBridgeAbstract, DealabsBridge, HotUKDealsBridge, MydealsBridge] (#3876)
Fix the Deal source link The HTML does not contain the link to the "Deal source anymore", now only an attribute does contain the information about the Deal Source. The JSON data is now extraced for each Deal, and used to get the Temperature and Deal Source.
This commit is contained in:
parent
12395fcf2d
commit
55ffac5bae
@ -1910,6 +1910,7 @@ class DealabsBridge extends PepperBridgeAbstract
|
||||
'context-talk' => 'Surveillance Discussion',
|
||||
'uri-group' => 'groupe/',
|
||||
'uri-deal' => 'bons-plans/',
|
||||
'uri-merchant' => 'search/bons-plans?merchant-id=',
|
||||
'request-error' => 'Impossible de joindre Dealabs',
|
||||
'thread-error' => 'Impossible de déterminer l\'ID de la discussion. Vérifiez l\'URL que vous avez entré',
|
||||
'no-results' => 'Il n'y a rien à afficher pour le moment :(',
|
||||
|
@ -3274,6 +3274,7 @@ class HotUKDealsBridge extends PepperBridgeAbstract
|
||||
'context-talk' => 'Discussion Monitoring',
|
||||
'uri-group' => 'tag/',
|
||||
'uri-deal' => 'deals/',
|
||||
'uri-merchant' => 'search/deals?merchant-id=',
|
||||
'request-error' => 'Could not request HotUKDeals',
|
||||
'thread-error' => 'Unable to determine the thread ID. Check the URL you entered',
|
||||
'no-results' => 'Ooops, looks like we could',
|
||||
|
@ -2021,6 +2021,7 @@ class MydealsBridge extends PepperBridgeAbstract
|
||||
'context-talk' => 'Überwachung Diskussion',
|
||||
'uri-group' => 'gruppe/',
|
||||
'uri-deal' => 'deals/',
|
||||
'uri-merchant' => 'search/gutscheine?merchant-id=',
|
||||
'request-error' => 'Could not request mydeals',
|
||||
'thread-error' => 'Die ID der Diskussion kann nicht ermittelt werden. Überprüfen Sie die eingegebene URL',
|
||||
'no-results' => 'Ups, wir konnten nichts',
|
||||
|
@ -104,6 +104,9 @@ class PepperBridgeAbstract extends BridgeAbstract
|
||||
$item['title'] = $this->getTitle($deal);
|
||||
$item['author'] = $deal->find('span.thread-username', 0)->plaintext;
|
||||
|
||||
// Get the JSON Data stored as vue
|
||||
$jsonDealData = $this->getDealJsonData($deal);
|
||||
|
||||
$item['content'] = '<table><tr><td><a href="'
|
||||
. $item['uri']
|
||||
. '"><img src="'
|
||||
@ -114,10 +117,10 @@ class PepperBridgeAbstract extends BridgeAbstract
|
||||
. $this->getDiscount($deal)
|
||||
. $this->getShipsFrom($deal)
|
||||
. $this->getShippingCost($deal)
|
||||
. $this->getSource($deal)
|
||||
. $this->getSource($jsonDealData)
|
||||
. $deal->find('div[class*=' . $selectorDescription . ']', 0)->innertext
|
||||
. '</td><td>'
|
||||
. $this->getTemperature($deal)
|
||||
. $this->getTemperature($jsonDealData)
|
||||
. '</td></table>';
|
||||
|
||||
// Check if a clock icon is displayed on the deal
|
||||
@ -371,21 +374,31 @@ HEREDOC;
|
||||
* Get the temperature from a Deal if it exists
|
||||
* @return string String of the deal temperature
|
||||
*/
|
||||
private function getTemperature($deal)
|
||||
private function getTemperature($data)
|
||||
{
|
||||
return $data['props']['thread']['temperature'] . '°';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the Deal data from the "data-vue2" JSON attribute
|
||||
* @return array Array containg the deal properties contained in the "data-vue2" attribute
|
||||
*/
|
||||
private function getDealJsonData($deal)
|
||||
{
|
||||
$data = Json::decode($deal->find('div[class=js-vue2]', 0)->getAttribute('data-vue2'));
|
||||
return $data['props']['thread']['temperature'] . '°';
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the source of a Deal if it exists
|
||||
* @return string String of the deal source
|
||||
*/
|
||||
private function getSource($deal)
|
||||
private function getSource($jsonData)
|
||||
{
|
||||
if (($origin = $deal->find('button[class*=text--color-greyShade]', 0)) != null) {
|
||||
$path = str_replace(' ', '/', trim(Json::decode($origin->{'data-cloak-link'})['path']));
|
||||
$text = $origin->find('span[class*=link]', 0);
|
||||
if ($jsonData['props']['thread']['merchant'] != null) {
|
||||
$path = $this->i8n('uri-merchant') . $jsonData['props']['thread']['merchant']['merchantId'];
|
||||
$text = $jsonData['props']['thread']['merchant']['merchantName'];
|
||||
return '<div>' . $this->i8n('origin') . ' : <a href="' . static::URI . $path . '">' . $text . '</a></div>';
|
||||
} else {
|
||||
return '';
|
||||
|
Loading…
x
Reference in New Issue
Block a user