2014-07-22 16:59:55 +04:00
|
|
|
<?php
|
|
|
|
class ScoopItBridge extends BridgeAbstract{
|
|
|
|
|
2016-08-30 12:23:55 +03:00
|
|
|
const MAINTAINER = "Pitchoule";
|
|
|
|
const NAME = "ScoopIt";
|
|
|
|
const URI = "http://www.scoop.it/";
|
|
|
|
const DESCRIPTION = "Returns most recent results from ScoopIt.";
|
2015-11-05 18:50:18 +03:00
|
|
|
|
2016-08-30 12:23:55 +03:00
|
|
|
const PARAMETERS = array( array(
|
2016-08-27 22:03:26 +03:00
|
|
|
'u'=>array(
|
2016-08-22 02:25:56 +03:00
|
|
|
'name'=>'keyword',
|
|
|
|
'required'=>true
|
2016-08-27 22:03:26 +03:00
|
|
|
)
|
|
|
|
));
|
2015-11-05 18:50:18 +03:00
|
|
|
|
2016-08-25 02:24:53 +03:00
|
|
|
public function collectData(){
|
2016-08-29 23:37:19 +03:00
|
|
|
$this->request = $this->getInput('u');
|
2016-08-30 12:23:55 +03:00
|
|
|
$link = self::URI.'search?q=' .urlencode($this->getInput('u'));
|
2016-07-08 20:06:35 +03:00
|
|
|
|
2016-08-29 23:37:19 +03:00
|
|
|
$html = $this->getSimpleHTMLDOM($link)
|
|
|
|
or $this->returnServerError('Could not request ScoopIt. for : ' . $link);
|
2016-07-08 20:06:35 +03:00
|
|
|
|
2016-08-29 23:37:19 +03:00
|
|
|
foreach($html->find('div.post-view') as $element) {
|
|
|
|
$item = array();
|
|
|
|
$item['uri'] = $element->find('a', 0)->href;
|
|
|
|
$item['title'] = preg_replace('~[[:cntrl:]]~', '', $element->find('div.tCustomization_post_title',0)->plaintext);
|
|
|
|
$item['content'] = preg_replace('~[[:cntrl:]]~', '', $element->find('div.tCustomization_post_description', 0)->plaintext);
|
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
2014-07-22 16:59:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getCacheDuration(){
|
|
|
|
return 21600; // 6 hours
|
|
|
|
}
|
|
|
|
}
|
2014-07-23 15:11:55 +04:00
|
|
|
|