mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-03-14 20:21:14 +03:00
[RaceDepartmentBridge] Follow site changes (#2087)
This commit is contained in:
parent
655e02e3fe
commit
2b793f04de
1 changed files with 11 additions and 25 deletions
|
@ -6,17 +6,21 @@ class RaceDepartmentBridge extends FeedExpander {
|
|||
const MAINTAINER = 't0stiman';
|
||||
|
||||
public function collectData() {
|
||||
$this->collectExpandableDatas('https://www.racedepartment.com/news/archive.rss', 10);
|
||||
$this->collectExpandableDatas('https://www.racedepartment.com/ams/index.rss', 10);
|
||||
}
|
||||
|
||||
protected function parseItem($feedItem) {
|
||||
$item = parent::parseItem($feedItem);
|
||||
$item = parent::parseRSS_2_0_Item($feedItem);
|
||||
|
||||
//fetch page
|
||||
$articlePage = getSimpleHTMLDOMCached($feedItem->link)
|
||||
or returnServerError('Could not retrieve ' . $feedItem->link);
|
||||
//extract article
|
||||
$item['content'] = $articlePage->find('div.thfeature_firstPost', 0);
|
||||
|
||||
$coverImage = $articlePage->find('img.js-articleCoverImage', 0);
|
||||
#relative url -> absolute url
|
||||
$coverImage = str_replace('src="/', 'src="' . $this->getURI() . '/', $coverImage);
|
||||
$article = $articlePage->find('article.articleBody-main > div.bbWrapper', 0);
|
||||
$item['content'] = str_get_html($coverImage . $article);
|
||||
|
||||
//convert iframes to links. meant for embedded videos.
|
||||
foreach($item['content']->find('iframe') as $found) {
|
||||
|
@ -28,29 +32,11 @@ class RaceDepartmentBridge extends FeedExpander {
|
|||
}
|
||||
}
|
||||
|
||||
//get rid of some elements we don't need
|
||||
$to_remove_selectors = array(
|
||||
'div.p-title', //title
|
||||
'ul.listInline', //Thread starter, Start date
|
||||
'div.rd_news_article_share_buttons',
|
||||
'div.thfeature_firstPost-author',
|
||||
'div.reactionsBar',
|
||||
'footer',
|
||||
'div.message-lastEdit',
|
||||
'section.message-attachments'
|
||||
);
|
||||
|
||||
foreach($to_remove_selectors as $selector) {
|
||||
foreach($item['content']->find($selector) as $found) {
|
||||
$found->outertext = '';
|
||||
}
|
||||
$item['categories'] = array();
|
||||
foreach($articlePage->find('a.tagItem') as $tag) {
|
||||
array_push($item['categories'], $tag->innertext);
|
||||
}
|
||||
|
||||
//category
|
||||
$forumPath = $articlePage->find('div.breadcrumb', 0);
|
||||
$pathElements = $forumPath->find('span');
|
||||
$item['categories'] = array(end($pathElements)->innertext);
|
||||
|
||||
return $item;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue