2014-07-22 16:59:55 +04:00
|
|
|
<?php
|
|
|
|
|
2022-07-01 16:10:30 +03: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 18:50:18 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
const PARAMETERS = [ [
|
|
|
|
'u' => [
|
|
|
|
'name' => 'keyword',
|
|
|
|
'exampleValue' => 'docker',
|
|
|
|
'required' => true
|
|
|
|
]
|
|
|
|
]];
|
2015-11-05 18:50:18 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
public function collectData()
|
|
|
|
{
|
|
|
|
$this->request = $this->getInput('u');
|
|
|
|
$link = self::URI . 'search?q=' . urlencode($this->getInput('u'));
|
2016-07-08 20:06:35 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
$html = getSimpleHTMLDOM($link);
|
2016-07-08 20:06:35 +03:00
|
|
|
|
2022-07-01 16:10:30 +03: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 18:16:56 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
$item['content'] = preg_replace(
|
|
|
|
'~[[:cntrl:]]~',
|
|
|
|
'',
|
|
|
|
$element->find('div.tCustomization_post_description', 0)->plaintext
|
|
|
|
);
|
2014-07-23 15:11:55 +04:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
|
|
|
}
|
2017-02-11 18:16:56 +03:00
|
|
|
}
|