Skip to content

Commit

Permalink
[FirstLookMediaTech]: New Bridge (#1438)
Browse files Browse the repository at this point in the history
  • Loading branch information
somini authored Feb 26, 2020
1 parent a3b4bd2 commit 90147fc
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions bridges/FirstLookMediaTechBridge.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php
class FirstLookMediaTechBridge extends BridgeAbstract {
const NAME = 'First Look Media - Technology';
const URI = 'https://tech.firstlook.media';
const DESCRIPTION = 'First Look Media Technology page';
const MAINTAINER = 'somini';
const PARAMETERS = array(
array(
'projects' => array(
'type' => 'checkbox',
'name' => 'Include Projects?',
)
)
);

public function collectData() {
$html = getSimpleHTMLDOM(self::URI)
or returnServerError('Could not load content');

if ($this->getInput('projects')) {
$top_projects = $html->find('.PromoList-ul', 0);
foreach($top_projects->find('li.PromoList-item') as $element) {
$item = array();

$item_uri = $element->find('a', 0);
$item['uri'] = $item_uri->href;
$item['title'] = strip_tags($item_uri->innertext);
$item['content'] = $element->find('div > div', 0);

$this->items[] = $item;
}
}

$top_articles = $html->find('.PromoList-ul', 1);
foreach($top_articles->find('li.PromoList-item') as $element) {
$item = array();

$item_left = $element->find('div > div', 0);
$item_date = $element->find('.PromoList-date', 0);
$item['timestamp'] = strtotime($item_date->innertext);
$item_date->outertext = ''; /* Remove */
$item['author'] = $item_left->innertext;
$item_uri = $element->find('a', 0);
$item['uri'] = self::URI . $item_uri->href;
$item['title'] = strip_tags($item_uri);

$this->items[] = $item;
}
}
}

0 comments on commit 90147fc

Please sign in to comment.