From acc0787b001613dffa343da8ddbec70b472105c8 Mon Sep 17 00:00:00 2001 From: Anchit Bajaj Date: Wed, 31 Jul 2019 17:56:43 +0530 Subject: [PATCH] [IGNBridge] - New bridge for IGN (#1233) * [IGNBridge]: New Bridge for IGN --- bridges/IGNBridge.php | 55 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 bridges/IGNBridge.php diff --git a/bridges/IGNBridge.php b/bridges/IGNBridge.php new file mode 100644 index 00000000..6a254b37 --- /dev/null +++ b/bridges/IGNBridge.php @@ -0,0 +1,55 @@ +collectExpandableDatas('http://feeds.ign.com/ign/all', 15); + } + + // IGNs feed is both hidden and incomplete. This bridge tries to fix this. + + protected function parseItem($newsItem){ + $item = parent::parseItem($newsItem); + + // $articlePage gets the entire page's contents + $articlePage = getSimpleHTMLDOM($newsItem->link); + + /* + * NOTE: Though articles and wiki/howtos have seperate styles of pages, there is no mechanism + * for handling them seperately as it just ignores the DOM querys which it does not find. + * (and their scraping) + */ + + // For Articles + $article = $articlePage->find('section.article-page', 0); + // add in verdicts in articles, reviews etc + foreach($articlePage->find('div.article-section') as $element) { + $article = $article . $element; + } + + // For Wikis and HowTos + $uselessWikiElements = array( + '.wiki-page-tools', + '.feedback-container', + '.paging-container' + ); + foreach($articlePage->find('.wiki-page') as $wikiContents) { + $copy = clone $wikiContents; + // Remove useless elements present in IGN wiki/howtos + foreach($uselessWikiElements as $uslElement) { + $toRemove = $wikiContents->find($uslElement, 0); + $copy = str_replace($toRemove, '', $copy); + } + $article = $article . $copy; + } + + // Add content to feed + $item['content'] = $article; + return $item; + } +}