From d45c6be3c5322c4a7a36d95964138e4bfc73ee72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Sun, 26 Jun 2016 11:52:54 +0200 Subject: [PATCH] add new bridge: Elsevier journals recent articles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pierre Mazière --- bridges/ElsevierBridge.php | 55 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 bridges/ElsevierBridge.php diff --git a/bridges/ElsevierBridge.php b/bridges/ElsevierBridge.php new file mode 100644 index 00000000..bb734777 --- /dev/null +++ b/bridges/ElsevierBridge.php @@ -0,0 +1,55 @@ +maintainer = 'Pierre Mazière'; + $this->name = 'Elsevier journals recent articles'; + $this->uri = 'http://www.journals.elsevier.com'; + $this->description = 'Returns the recent articles published in Elsevier journals'; + $this->update = '2016-06-26'; + + $this->parameters= + '[ + { + "name" : "Journal name", + "identifier" : "j" + } + ]'; + } + + public function collectData(array $param){ + $uri = 'http://www.journals.elsevier.com/'.$param['j'].'/recent-articles/'; + $html = file_get_html($uri) + or $this->returnError('No results for Elsevier journal '.$param['j'], 404); + + foreach($html->find('.pod-listing') as $article){ + + $item = new \Item(); + $item->uri=$article->find('.pod-listing-header>a',0)->getAttribute('href').'?np=y'; + $item->title=$article->find('.pod-listing-header>a',0)->plaintext; + $item->name=trim($article->find('small',0)->plaintext); + $item->timestamp=strtotime($article->find('.article-info',0)->plaintext); + $item->content=trim($article->find('.article-content',0)->plaintext); + + $this->items[]=$item; + } + } + + public function getName(){ + return 'Elsevier journals recent articles'; + } + + public function getURI(){ + return 'http://www.journals.elsevier.com'; + } + + public function getCacheDuration(){ + return 43200; // 12h + } +}