2022-03-23 02:43:26 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class StanfordSIRbookreviewBridge extends BridgeAbstract
|
2022-07-01 16:10:30 +03:00
|
|
|
{
|
2022-03-23 02:43:26 +03:00
|
|
|
const MAINTAINER = 'Kidman1670';
|
|
|
|
const NAME = 'StanfordSIRbookreviewBridge';
|
|
|
|
const URI = 'https://ssir.org/books/';
|
|
|
|
const CACHE_TIMEOUT = 21600;
|
|
|
|
const DESCRIPTION = 'Return results from SSIR book review.';
|
|
|
|
const PARAMETERS = [ [
|
|
|
|
'style' => [
|
|
|
|
'name' => 'style',
|
|
|
|
'type' => 'list',
|
|
|
|
'values' => [
|
|
|
|
'reviews' => 'reviews',
|
|
|
|
'excerpts' => 'excerpts',
|
2022-07-01 16:10:30 +03:00
|
|
|
]
|
|
|
|
]
|
|
|
|
]
|
2022-03-23 02:43:26 +03:00
|
|
|
];
|
|
|
|
|
|
|
|
public function collectData()
|
2022-07-01 16:10:30 +03:00
|
|
|
{
|
2022-03-23 02:43:26 +03:00
|
|
|
switch ($this->getInput('style')) {
|
|
|
|
case 'reviews':
|
|
|
|
$url = self::URI . 'reviews';
|
2022-07-01 16:10:30 +03:00
|
|
|
break;
|
2022-03-23 02:43:26 +03:00
|
|
|
case 'excerpts':
|
|
|
|
$url = self::URI . 'excerpts';
|
|
|
|
break;
|
2022-07-01 16:10:30 +03:00
|
|
|
}
|
2022-03-23 02:43:26 +03:00
|
|
|
|
|
|
|
$html = getSimpleHTMLDOM($url)
|
|
|
|
or returnServerError('Failed loading content!');
|
|
|
|
foreach ($html->find('article') as $element) {
|
2022-07-01 16:10:30 +03:00
|
|
|
$item = [];
|
2022-03-23 02:43:26 +03:00
|
|
|
$item['title'] = $element->find('div > h4 > a', 0)->plaintext;
|
|
|
|
$item['uri'] = $element->find('div > h4 > a', 0)->href;
|
|
|
|
$item['content'] = $element->find('div > div.article-entry > p', 2)->plaintext;
|
|
|
|
$item['author'] = $element->find('div > div > p', 0)->plaintext;
|
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
}
|
2022-03-23 02:43:26 +03:00
|
|
|
}
|