From 5caca6267715d154be5b4934ac9913a96d641427 Mon Sep 17 00:00:00 2001 From: Corentin Garcia Date: Fri, 14 Jul 2017 22:05:51 +0200 Subject: [PATCH] Update RainbowSixSiegeBridge (#548) * Fix non-working RainbowSixSiegeBridge * Updated RainbowSixSiegeBridge to use API to fetch articles * Fix RainbowSixSiegeBridge coding style * RainbowSixSiegeBridge fix url coding style error --- bridges/RainbowSixSiegeBridge.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/bridges/RainbowSixSiegeBridge.php b/bridges/RainbowSixSiegeBridge.php index 27f2e5b..1e0fa9d 100644 --- a/bridges/RainbowSixSiegeBridge.php +++ b/bridges/RainbowSixSiegeBridge.php @@ -8,23 +8,27 @@ class RainbowSixSiegeBridge extends BridgeAbstract { const DESCRIPTION = 'Latest articles from the Rainbow Six Siege blog'; public function collectData(){ - $html = getSimpleHTMLDOM(self::URI . 'index.aspx') - or returnServerError('Error while downloading the website content'); + $dlUrl = "https://prod-tridionservice.ubisoft.com/live/v1/News/Latest?templateId=tcm%3A152-7677"; + $dlUrl .= "8-32&pageIndex=0&pageSize=10&language=en-US&detailPageId=tcm%3A152-194572-64"; + $dlUrl .= "&keywordList=175426&siteId=undefined&useSeoFriendlyUrl=true"; + $jsonString = getContents($dlUrl) or returnServerError('Error while downloading the website content'); - $list = $html->find('.comdev'); + $json = json_decode($jsonString, true); + $json = $json['items']; // Start at index 2 to remove highlighted articles - for($i = 2; $i < count($list); $i++){ - $article = $list[$i]; + for($i = 0; $i < count($json); $i++){ + $jsonItem = $json[$i]['Content']; + $article = str_get_html($jsonItem); $item = array(); $uri = $article->find('h3 a', 0)->href; $uri = 'https://rainbow6.ubisoft.com' . $uri; $item['uri'] = $uri; - $item['title'] = $article->find('h3 a', 0)->plaintext; - $item['content'] = $article->find('a', 0)->innertext . '
' . $article->find('strong', 0)->plaintext; - $item['timestamp'] = strtotime($article->find('p', 0)->plaintext); + $item['title'] = $article->find('h3', 0)->plaintext; + $item['content'] = $article->find('img', 0)->outertext . '
' . $article->find('strong', 0)->plaintext; + $item['timestamp'] = strtotime($article->find('p.news_date', 0)->plaintext); $this->items[] = $item; }