2014-07-22 14:59:55 +02:00
|
|
|
<?php
|
|
|
|
|
2022-07-01 15:10:30 +02:00
|
|
|
class ScoopItBridge extends BridgeAbstract
|
|
|
|
{
|
|
|
|
const MAINTAINER = 'Pitchoule';
|
|
|
|
const NAME = 'ScoopIt';
|
|
|
|
const URI = 'https://www.scoop.it/';
|
|
|
|
const CACHE_TIMEOUT = 21600; // 6h
|
|
|
|
const DESCRIPTION = 'Returns most recent results from ScoopIt.';
|
2015-11-05 15:50:18 +00:00
|
|
|
|
2022-07-01 15:10:30 +02:00
|
|
|
const PARAMETERS = [ [
|
|
|
|
'u' => [
|
|
|
|
'name' => 'keyword',
|
|
|
|
'exampleValue' => 'docker',
|
|
|
|
'required' => true
|
|
|
|
]
|
|
|
|
]];
|
2015-11-05 15:50:18 +00:00
|
|
|
|
2022-07-01 15:10:30 +02:00
|
|
|
public function collectData()
|
|
|
|
{
|
|
|
|
$this->request = $this->getInput('u');
|
|
|
|
$link = self::URI . 'search?q=' . urlencode($this->getInput('u'));
|
2016-07-08 19:06:35 +02:00
|
|
|
|
2022-07-01 15:10:30 +02:00
|
|
|
$html = getSimpleHTMLDOM($link);
|
2016-07-08 19:06:35 +02:00
|
|
|
|
2022-07-01 15:10:30 +02:00
|
|
|
foreach ($html->find('div.post-view') as $element) {
|
|
|
|
$item = [];
|
|
|
|
$item['uri'] = $element->find('a', 0)->href;
|
|
|
|
$item['title'] = preg_replace(
|
|
|
|
'~[[:cntrl:]]~',
|
|
|
|
'',
|
|
|
|
$element->find('div.tCustomization_post_title', 0)->plaintext
|
|
|
|
);
|
2017-02-11 16:16:56 +01:00
|
|
|
|
2022-07-01 15:10:30 +02:00
|
|
|
$item['content'] = preg_replace(
|
|
|
|
'~[[:cntrl:]]~',
|
|
|
|
'',
|
|
|
|
$element->find('div.tCustomization_post_description', 0)->plaintext
|
|
|
|
);
|
2014-07-23 13:11:55 +02:00
|
|
|
|
2022-07-01 15:10:30 +02:00
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
|
|
|
}
|
2017-02-11 16:16:56 +01:00
|
|
|
}
|