mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-04-09 16:38:50 +00:00
[NYTBridge] Fix article parsing (#2106)
Co-authored-by: podiki <podiki@users.noreply.github.com>
This commit is contained in:
parent
9399ebb2c6
commit
0de2db853f
@ -4,22 +4,33 @@ class NYTBridge extends FeedExpander {
|
|||||||
const MAINTAINER = 'IceWreck';
|
const MAINTAINER = 'IceWreck';
|
||||||
const NAME = 'New York Times Bridge';
|
const NAME = 'New York Times Bridge';
|
||||||
const URI = 'https://www.nytimes.com/';
|
const URI = 'https://www.nytimes.com/';
|
||||||
const CACHE_TIMEOUT = 3600;
|
const CACHE_TIMEOUT = 900; // 15 minutes
|
||||||
const DESCRIPTION = 'RSS feed for the New York Times';
|
const DESCRIPTION = 'RSS feed for the New York Times';
|
||||||
|
|
||||||
public function collectData(){
|
public function collectData(){
|
||||||
$this->collectExpandableDatas('https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml', 15);
|
$this->collectExpandableDatas('https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml', 40);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function parseItem($newsItem){
|
protected function parseItem($newsItem){
|
||||||
$item = parent::parseItem($newsItem);
|
$item = parent::parseItem($newsItem);
|
||||||
|
$article = '';
|
||||||
|
|
||||||
// $articlePage gets the entire page's contents
|
// $articlePage gets the entire page's contents
|
||||||
$articlePage = getSimpleHTMLDOM($newsItem->link);
|
$articlePage = getSimpleHTMLDOM($newsItem->link);
|
||||||
|
|
||||||
|
// handle subtitle
|
||||||
|
$subtitle = $articlePage->find('p.css-w6ymp8', 0);
|
||||||
|
if ($subtitle != null) {
|
||||||
|
$article .= '<strong>' . $subtitle->plaintext . '</strong>';
|
||||||
|
}
|
||||||
|
|
||||||
// figure contain's the main article image
|
// figure contain's the main article image
|
||||||
$article = $articlePage->find('figure', 0);
|
$article .= $articlePage->find('figure', 0) . '<br />';
|
||||||
// p > css-exrw3m has the actual article
|
|
||||||
foreach($articlePage->find('p.css-exrw3m') as $element)
|
// section.meteredContent has the actual article
|
||||||
$article = $article . $element;
|
foreach($articlePage->find('section.meteredContent p') as $element)
|
||||||
|
$article .= '' . $element . '';
|
||||||
|
|
||||||
$item['content'] = $article;
|
$item['content'] = $article;
|
||||||
return $item;
|
return $item;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user