From 82606a479a75cd4eff4740ba49715b3135c89c49 Mon Sep 17 00:00:00 2001 From: sysadminstory Date: Thu, 4 Apr 2024 04:08:29 +0200 Subject: [PATCH] [PepperBridgeAbstract,DealabsBridge,HotUKDealsBridge,MydealsBridge] Fix search URL, No results handling fixed, Thread title and Message URL handling (#4053) * [PepperBridgeAbstract,DealabsBridge,HotUKDealsBridge,MydealsBridge] Fix search URL, No results handling fixed, Thread title and Message URL handling Search URL has been updated according to the website. If a search doesn't return any results, the HTML won't contain any specific text now : the HTML structure is slightly different, so the bridge has been updated. The unnneded 'no-results' text is now removed from the specific bridges. The board thread title has been removed from the content, so now we use the page element. In case a board message is empty, there was an exception during the filtering of message without URL. * [PepperBridgeAbstract,DealabsBridge,HotUKDealsBridge,MydealsBridge] Fix search URL, No results handling fixed, Thread title and Message URL handling Coding policy fixes --- bridges/DealabsBridge.php | 1 - bridges/HotUKDealsBridge.php | 1 - bridges/MydealsBridge.php | 1 - bridges/PepperBridgeAbstract.php | 25 ++++++++++++++----------- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/bridges/DealabsBridge.php b/bridges/DealabsBridge.php index 62d854f6235..3ee1c6f5464 100644 --- a/bridges/DealabsBridge.php +++ b/bridges/DealabsBridge.php @@ -1913,7 +1913,6 @@ class DealabsBridge extends PepperBridgeAbstract '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' => 'Aucun résultat', 'currency' => '€', 'price' => 'Prix', 'shipping' => 'Livraison', diff --git a/bridges/HotUKDealsBridge.php b/bridges/HotUKDealsBridge.php index b631db7338b..6958220e645 100644 --- a/bridges/HotUKDealsBridge.php +++ b/bridges/HotUKDealsBridge.php @@ -3277,7 +3277,6 @@ class HotUKDealsBridge extends PepperBridgeAbstract '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' => 'no results', 'currency' => '£', 'price' => 'Price', 'shipping' => 'Shipping', diff --git a/bridges/MydealsBridge.php b/bridges/MydealsBridge.php index 41bae46cd53..7b23f263936 100644 --- a/bridges/MydealsBridge.php +++ b/bridges/MydealsBridge.php @@ -2024,7 +2024,6 @@ class MydealsBridge extends PepperBridgeAbstract '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' => 'keine Ergebnisse', 'currency' => '€', 'price' => 'Preis', 'shipping' => 'Versand', diff --git a/bridges/PepperBridgeAbstract.php b/bridges/PepperBridgeAbstract.php index 7b40ea1c6cf..33d427bc05b 100644 --- a/bridges/PepperBridgeAbstract.php +++ b/bridges/PepperBridgeAbstract.php @@ -55,8 +55,8 @@ protected function collectDeals($url) ); // If there is no results, we don't parse the content because it display some random deals - $noresult = $html->find('h3[class*=text--b]', 0); - if ($noresult != null && strpos($noresult->plaintext, $this->i8n('no-results')) !== false) { + $noresult = $html->find('section[class=subNav]', 0)->find('div[class*=page-center listLayout aGrid]', 0); + if ($noresult === null) { $this->items = []; } else { foreach ($list as $deal) { @@ -174,13 +174,16 @@ protected function collectDataTalk() $item['uid'] = $comment->commentId; // Timestamp handling needs a new parsing function if ($onlyWithUrl == true) { - // Count Links and Quote Links - $content = str_get_html($item['content']); - $countLinks = count($content->find('a[href]')); - $countQuoteLinks = count($content->find('a[href][class=userHtml-quote-source]')); - // Only add element if there are Links ans more links tant Quote links - if ($countLinks > 0 && $countLinks > $countQuoteLinks) { - $this->items[] = $item; + // Only parse the comment if it is not empry + if ($item['content'] != '') { + // Count Links and Quote Links + $content = str_get_html($item['content']); + $countLinks = count($content->find('a[href]')); + $countQuoteLinks = count($content->find('a[href][class=userHtml-quote-source]')); + // Only add element if there are Links and more links tant Quote links + if ($countLinks > 0 && $countLinks > $countQuoteLinks) { + $this->items[] = $item; + } } } else { $this->items[] = $item; @@ -264,7 +267,7 @@ private function getTitle($jsonDealData) private function getTalkTitle() { $html = getSimpleHTMLDOMCached($this->getInput('url')); - $title = $html->find('.thread-title', 0)->plaintext; + $title = $html->find('title', 0)->plaintext; return $title; } @@ -472,7 +475,7 @@ private function getSearchURI() $priceFrom = $this->getInput('priceFrom'); $priceTo = $this->getInput('priceTo'); $url = $this->i8n('bridge-uri') - . 'search/advanced?q=' + . 'search?q=' . urlencode($q) . '&hide_expired=' . $hide_expired . '&hide_local=' . $hide_local