2019-07-29 13:15:08 +03:00
|
|
|
<?php
|
|
|
|
class NYTBridge extends FeedExpander {
|
|
|
|
|
|
|
|
const MAINTAINER = 'IceWreck';
|
|
|
|
const NAME = 'New York Times Bridge';
|
|
|
|
const URI = 'https://www.nytimes.com/';
|
2021-06-30 13:14:25 +03:00
|
|
|
const CACHE_TIMEOUT = 900; // 15 minutes
|
2019-07-29 13:15:08 +03:00
|
|
|
const DESCRIPTION = 'RSS feed for the New York Times';
|
|
|
|
|
|
|
|
public function collectData(){
|
2021-06-30 13:14:25 +03:00
|
|
|
$this->collectExpandableDatas('https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml', 40);
|
2019-07-29 13:15:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function parseItem($newsItem){
|
|
|
|
$item = parent::parseItem($newsItem);
|
2021-06-30 13:14:25 +03:00
|
|
|
$article = '';
|
|
|
|
|
2019-07-29 13:15:08 +03:00
|
|
|
// $articlePage gets the entire page's contents
|
|
|
|
$articlePage = getSimpleHTMLDOM($newsItem->link);
|
2021-06-30 13:14:25 +03:00
|
|
|
|
|
|
|
// handle subtitle
|
|
|
|
$subtitle = $articlePage->find('p.css-w6ymp8', 0);
|
|
|
|
if ($subtitle != null) {
|
|
|
|
$article .= '<strong>' . $subtitle->plaintext . '</strong>';
|
|
|
|
}
|
|
|
|
|
2019-07-29 13:15:08 +03:00
|
|
|
// figure contain's the main article image
|
2021-06-30 13:14:25 +03:00
|
|
|
$article .= $articlePage->find('figure', 0) . '<br />';
|
|
|
|
|
|
|
|
// section.meteredContent has the actual article
|
|
|
|
foreach($articlePage->find('section.meteredContent p') as $element)
|
|
|
|
$article .= '' . $element . '';
|
|
|
|
|
2019-07-29 13:15:08 +03:00
|
|
|
$item['content'] = $article;
|
|
|
|
return $item;
|
|
|
|
}
|
|
|
|
}
|