mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-02-12 21:29:56 +03:00
various fixes (#3190)
* fix: Call to a member function parent() on null * fix: notice fixes Trying to get property plaintext of non-object at bridges/WikiLeaksBridge.php line 96 * fix: CommonDreamsBridge
This commit is contained in:
parent
a13c4624fb
commit
936ae8cca3
3 changed files with 76 additions and 65 deletions
|
@ -21,10 +21,11 @@ class CommonDreamsBridge extends FeedExpander
|
|||
|
||||
private function extractContent($url)
|
||||
{
|
||||
$html3 = getSimpleHTMLDOMCached($url);
|
||||
$text = $html3->find('div[class=field--type-text-with-summary]', 0)->innertext;
|
||||
$html3->clear();
|
||||
unset($html3);
|
||||
$dom = getSimpleHTMLDOMCached($url);
|
||||
$summary = $dom->find('div.node__body', 0);
|
||||
$text = $summary->innertext;
|
||||
$dom->clear();
|
||||
unset($dom);
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,10 +13,16 @@ class TheHackerNewsBridge extends BridgeAbstract
|
|||
$limit = 0;
|
||||
|
||||
foreach ($html->find('div.body-post') as $element) {
|
||||
if ($limit < 5) {
|
||||
$article_url = $element->find('a.story-link', 0)->href;
|
||||
$article_author = trim($element->find('i.icon-user', 0)->parent()->plaintext);
|
||||
if ($limit >= 5) {
|
||||
break;
|
||||
}
|
||||
|
||||
$article_author = null;
|
||||
$icon_user = $element->find('i.icon-user', 0);
|
||||
if ($icon_user) {
|
||||
$article_author = trim($icon_user->parent()->plaintext);
|
||||
$article_author = str_replace('', '', $article_author);
|
||||
}
|
||||
$article_title = $element->find('h2.home-title', 0)->plaintext;
|
||||
|
||||
$article_timestamp = time();
|
||||
|
@ -45,6 +51,7 @@ class TheHackerNewsBridge extends BridgeAbstract
|
|||
$article_thumbnail = [];
|
||||
}
|
||||
|
||||
$article_url = $element->find('a.story-link', 0)->href;
|
||||
$article = getSimpleHTMLDOMCached($article_url);
|
||||
if ($article) {
|
||||
//Article body
|
||||
|
@ -72,7 +79,9 @@ class TheHackerNewsBridge extends BridgeAbstract
|
|||
$item = [];
|
||||
$item['uri'] = $article_url;
|
||||
$item['title'] = $article_title;
|
||||
if ($article_author) {
|
||||
$item['author'] = $article_author;
|
||||
}
|
||||
$item['enclosures'] = $article_thumbnail;
|
||||
$item['timestamp'] = $article_timestamp;
|
||||
$item['content'] = trim($contents ?? '');
|
||||
|
@ -81,4 +90,3 @@ class TheHackerNewsBridge extends BridgeAbstract
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,8 +93,10 @@ class WikiLeaksBridge extends BridgeAbstract
|
|||
$item['title'] = $article->find('h3', 0)->plaintext;
|
||||
$item['uri'] = static::URI . $article->find('h3 a', 0)->href;
|
||||
$item['content'] = $article->find('div.introduction', 0)->plaintext;
|
||||
$item['timestamp'] = strtotime($article->find('div.timestamp', 0)->plaintext);
|
||||
|
||||
$timestamp = $article->find('div.timestamp', 0);
|
||||
if ($timestamp) {
|
||||
$item['timestamp'] = strtotime($timestamp->plaintext);
|
||||
}
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue