From 579bfa669cd809bd04fd6411d25e1d36f596887f Mon Sep 17 00:00:00 2001 From: Joseph Date: Fri, 2 Apr 2021 13:01:51 +0000 Subject: [PATCH] [WallmineNewsBridge] Add bridge (#2035) --- bridges/WallmineNewsBridge.php | 50 ++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 bridges/WallmineNewsBridge.php diff --git a/bridges/WallmineNewsBridge.php b/bridges/WallmineNewsBridge.php new file mode 100644 index 00000000..bbcfcf31 --- /dev/null +++ b/bridges/WallmineNewsBridge.php @@ -0,0 +1,50 @@ +getURI() . '/news/') + or returnServerError('Could not request: ' . $this->getURI() . '/news/'); + + $html = defaultLinkTo($html, self::URI); + + foreach($html->find('div.container.news-card') as $div) { + $item = array(); + $item['uri'] = $div->find('a', 0)->href; + + $image = $div->find('img.img-fluid', 0)->src; + + $page = getSimpleHTMLDOMCached($item['uri'], 7200) + or returnServerError('Could not request: ' . $item['uri']); + + $article = $page->find('div.container.article-container', 0); + + $item['title'] = $article->find('h1', 0)->plaintext; + + $article->find('p.published-on', 0)->children(0)->outertext = ''; + $article->find('p.published-on', 0)->children(1)->outertext = ''; + $date = str_replace('at', '', $article->find('p.published-on', 0)->innertext); + + $item['timestamp'] = $date; + + $article->find('h1', 0)->outertext = ''; + $article->find('p.published-on', 0)->outertext = ''; + + $item['content'] = $article->innertext; + $item['enclosures'][] = $image; + + $this->items[] = $item; + + if (count($this->items) >= 10) { + break; + } + } + + } +}