mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-04-09 16:38:50 +00:00
fix carthrottlebridge (#3633)
This commit is contained in:
parent
eb4ff7099f
commit
0325c2414a
@ -1,44 +1,45 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class CarThrottleBridge extends FeedExpander
|
class CarThrottleBridge extends BridgeAbstract
|
||||||
{
|
{
|
||||||
const NAME = 'Car Throttle ';
|
const NAME = 'Car Throttle';
|
||||||
const URI = 'https://www.carthrottle.com';
|
const URI = 'https://www.carthrottle.com/';
|
||||||
const DESCRIPTION = 'Get the latest car-related news from Car Throttle.';
|
const DESCRIPTION = 'Get the latest car-related news from Car Throttle.';
|
||||||
const MAINTAINER = 't0stiman';
|
const MAINTAINER = 't0stiman';
|
||||||
|
|
||||||
public function collectData()
|
public function collectData()
|
||||||
{
|
{
|
||||||
$this->collectExpandableDatas('https://www.carthrottle.com/rss', 10);
|
$news = getSimpleHTMLDOMCached(self::URI . 'news')
|
||||||
}
|
or returnServerError('could not retrieve page');
|
||||||
|
|
||||||
protected function parseItem($feedItem)
|
$this->items[] = [];
|
||||||
{
|
|
||||||
$item = parent::parseItem($feedItem);
|
|
||||||
|
|
||||||
//fetch page
|
//for each post
|
||||||
$articlePage = getSimpleHTMLDOMCached($feedItem->link)
|
foreach ($news->find('div.cmg-card') as $post) {
|
||||||
or returnServerError('Could not retrieve ' . $feedItem->link);
|
$item = [];
|
||||||
|
|
||||||
$subtitle = $articlePage->find('p.standfirst', 0);
|
$titleElement = $post->find('div.title a.cmg-link')[0];
|
||||||
$article = $articlePage->find('div.content_field', 0);
|
$item['uri'] = self::URI . $titleElement->getAttribute('href');
|
||||||
|
$item['title'] = $titleElement->innertext;
|
||||||
|
|
||||||
$item['content'] = str_get_html($subtitle . $article);
|
$articlePage = getSimpleHTMLDOMCached($item['uri'])
|
||||||
|
or returnServerError('could not retrieve page');
|
||||||
|
|
||||||
//convert <iframe>s to <a>s. meant for embedded videos.
|
$item['author'] = $articlePage->find('div.author div')[1]->innertext;
|
||||||
foreach ($item['content']->find('iframe') as $found) {
|
|
||||||
$iframeUrl = $found->getAttribute('src');
|
|
||||||
|
|
||||||
if ($iframeUrl) {
|
$dinges = $articlePage->find('div.main-body')[0];
|
||||||
$found->outertext = '<a href="' . $iframeUrl . '">' . $iframeUrl . '</a>';
|
//remove ads
|
||||||
|
foreach ($dinges->find('aside') as $ad) {
|
||||||
|
$ad->outertext = '';
|
||||||
|
$dinges->save();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//remove scripts from the text
|
$item['content'] = $articlePage->find('div.summary')[0] .
|
||||||
foreach ($item['content']->find('script') as $remove) {
|
$articlePage->find('figure.main-image')[0] .
|
||||||
$remove->outertext = '';
|
$dinges;
|
||||||
}
|
|
||||||
|
|
||||||
return $item;
|
//add the item to the list
|
||||||
|
array_push($this->items, $item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user