From d7e2d65ff7787507cc4071f6b7214e91ecf4e72f Mon Sep 17 00:00:00 2001 From: gsurrel Date: Thu, 2 Jan 2014 11:42:39 +0100 Subject: [PATCH] Added Wikipedia EN bridge (Today's featured article) --- bridges/WikipediaENBridge.php | 41 +++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 bridges/WikipediaENBridge.php diff --git a/bridges/WikipediaENBridge.php b/bridges/WikipediaENBridge.php new file mode 100755 index 00000000..ecd2ccf5 --- /dev/null +++ b/bridges/WikipediaENBridge.php @@ -0,0 +1,41 @@ +returnError('Could not request Wikipedia EN.', 404); + + $element = $html->find('div[id=mp-tfa]', 0); + // Clean the bottom of the featured article + $element->find('div', -1)->outertext = ''; + $item = new \Item(); + $item->uri = $host.$element->find('p', 0)->find('a', 0)->href; + $item->title = $element->find('p',0)->find('a',0)->title; + $item->content = str_replace('href="/', 'href="'.$host.'/', $element->innertext); + $this->items[] = $item; + } + + public function getName(){ + return 'Wikipedia EN "Today\'s Featued Article"'; + } + + public function getURI(){ + return 'https://en.wikipedia.org/wiki/Main_Page'; + } + + public function getCacheDuration(){ + return 3600*4; // 4 hours + } +}