mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-04-23 15:06:53 +00:00
apply phpcbf using project settings
This commit is contained in:
parent
ef5a9973f0
commit
7d551a3782
@ -1,61 +1,61 @@
|
|||||||
<?php
|
<?php
|
||||||
class BloombergBridge extends BridgeAbstract
|
class BloombergBridge extends BridgeAbstract
|
||||||
{
|
{
|
||||||
const NAME = 'Bloomberg';
|
const NAME = 'Bloomberg';
|
||||||
const URI = 'https://www.bloomberg.com/';
|
const URI = 'https://www.bloomberg.com/';
|
||||||
const DESCRIPTION = 'Trending stories from Bloomberg';
|
const DESCRIPTION = 'Trending stories from Bloomberg';
|
||||||
const MAINTAINER = 'mdemoss';
|
const MAINTAINER = 'mdemoss';
|
||||||
|
|
||||||
const PARAMETERS = array(
|
const PARAMETERS = array(
|
||||||
'Trending Stories' => array(),
|
'Trending Stories' => array(),
|
||||||
'From Search' => array(
|
'From Search' => array(
|
||||||
'q' => array(
|
'q' => array(
|
||||||
'name' => 'Keyword',
|
'name' => 'Keyword',
|
||||||
'required' => true
|
'required' => true
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
public function getName()
|
public function getName()
|
||||||
{
|
{
|
||||||
switch($this->queriedContext) {
|
switch($this->queriedContext) {
|
||||||
case 'Trending Stories':
|
case 'Trending Stories':
|
||||||
return self::NAME . ' Trending Stories';
|
return self::NAME . ' Trending Stories';
|
||||||
case 'From Search':
|
case 'From Search':
|
||||||
if (!is_null($this->getInput('q'))) {
|
if (!is_null($this->getInput('q'))) {
|
||||||
return self::NAME . ' Search : ' . $this->getInput('q');
|
return self::NAME . ' Search : ' . $this->getInput('q');
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::getName();
|
return parent::getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function collectData()
|
public function collectData()
|
||||||
{
|
{
|
||||||
switch($this->queriedContext) {
|
switch($this->queriedContext) {
|
||||||
case 'Trending Stories': // Get list of top new <article>s from the front page.
|
case 'Trending Stories': // Get list of top new <article>s from the front page.
|
||||||
$html = getSimpleHTMLDOMCached($this->getURI(), 300);
|
$html = getSimpleHTMLDOMCached($this->getURI(), 300);
|
||||||
$stories = $html->find('ul.top-news-v3__stories article.top-news-v3-story');
|
$stories = $html->find('ul.top-news-v3__stories article.top-news-v3-story');
|
||||||
break;
|
break;
|
||||||
case 'From Search': // Get list of <article> elements from search.
|
case 'From Search': // Get list of <article> elements from search.
|
||||||
$html = getSimpleHTMLDOMCached($this->getURI() . 'search?sort=time:desc&page=1&query=' . urlencode($this->getInput('q')), 300);
|
$html = getSimpleHTMLDOMCached($this->getURI() . 'search?sort=time:desc&page=1&query=' . urlencode($this->getInput('q')), 300);
|
||||||
$stories = $html->find('div.search-result-items article.search-result-story');
|
$stories = $html->find('div.search-result-items article.search-result-story');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
foreach ($stories as $element) {
|
foreach ($stories as $element) {
|
||||||
$item['uri'] = $element->find('h1 a', 0)->href;
|
$item['uri'] = $element->find('h1 a', 0)->href;
|
||||||
if (preg_match('#^https://#i', $item['uri']) !== 1) {
|
if (preg_match('#^https://#i', $item['uri']) !== 1) {
|
||||||
$item['uri'] = $this->getURI() . $item['uri'];
|
$item['uri'] = $this->getURI() . $item['uri'];
|
||||||
}
|
}
|
||||||
$articleHtml = getSimpleHTMLDOMCached($item['uri']);
|
$articleHtml = getSimpleHTMLDOMCached($item['uri']);
|
||||||
if (!$articleHtml) {
|
if (!$articleHtml) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$item['title'] = $element->find('h1 a', 0)->plaintext;
|
$item['title'] = $element->find('h1 a', 0)->plaintext;
|
||||||
$item['timestamp'] = strtotime($articleHtml->find('meta[name=iso-8601-publish-date],meta[name=date]', 0)->content);
|
$item['timestamp'] = strtotime($articleHtml->find('meta[name=iso-8601-publish-date],meta[name=date]', 0)->content);
|
||||||
$item['content'] = $articleHtml->find('meta[name=description]', 0)->content;
|
$item['content'] = $articleHtml->find('meta[name=description]', 0)->content;
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user