mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-04-09 16:38:50 +00:00
fix: TheHackerNewsBridge (#3154)
This commit is contained in:
parent
88766e6fde
commit
745a7ba122
@ -19,14 +19,18 @@ class TheHackerNewsBridge extends BridgeAbstract
|
|||||||
$article_author = str_replace('', '', $article_author);
|
$article_author = str_replace('', '', $article_author);
|
||||||
$article_title = $element->find('h2.home-title', 0)->plaintext;
|
$article_title = $element->find('h2.home-title', 0)->plaintext;
|
||||||
|
|
||||||
|
$article_timestamp = time();
|
||||||
//Date without time
|
//Date without time
|
||||||
$article_timestamp = strtotime(
|
$calendar = $element->find('i.icon-calendar', 0);
|
||||||
extractFromDelimiters(
|
if ($calendar) {
|
||||||
$element->find('i.icon-calendar', 0)->parent()->outertext,
|
$article_timestamp = strtotime(
|
||||||
'</i>',
|
extractFromDelimiters(
|
||||||
'<span>'
|
$calendar->parent()->outertext,
|
||||||
)
|
'</i>',
|
||||||
);
|
'<span>'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
//Article thumbnail in lazy-loading image
|
//Article thumbnail in lazy-loading image
|
||||||
if (is_object($element->find('img[data-echo]', 0))) {
|
if (is_object($element->find('img[data-echo]', 0))) {
|
||||||
@ -41,13 +45,16 @@ class TheHackerNewsBridge extends BridgeAbstract
|
|||||||
$article_thumbnail = [];
|
$article_thumbnail = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($article = getSimpleHTMLDOMCached($article_url)) {
|
$article = getSimpleHTMLDOMCached($article_url);
|
||||||
|
if ($article) {
|
||||||
//Article body
|
//Article body
|
||||||
$contents = $article->find('div.articlebody', 0)->innertext;
|
$var = $article->find('div.articlebody', 0);
|
||||||
$contents = stripRecursiveHtmlSection($contents, 'div', '<div class="ad_');
|
if ($var) {
|
||||||
$contents = stripWithDelimiters($contents, 'id="google_ads', '</iframe>');
|
$contents = $var->innertext;
|
||||||
$contents = stripWithDelimiters($contents, '<script', '</script>');
|
$contents = stripRecursiveHtmlSection($contents, 'div', '<div class="ad_');
|
||||||
|
$contents = stripWithDelimiters($contents, 'id="google_ads', '</iframe>');
|
||||||
|
$contents = stripWithDelimiters($contents, '<script', '</script>');
|
||||||
|
}
|
||||||
//Date with time
|
//Date with time
|
||||||
if (is_object($article->find('meta[itemprop=dateModified]', 0))) {
|
if (is_object($article->find('meta[itemprop=dateModified]', 0))) {
|
||||||
$article_timestamp = strtotime(
|
$article_timestamp = strtotime(
|
||||||
@ -68,7 +75,7 @@ class TheHackerNewsBridge extends BridgeAbstract
|
|||||||
$item['author'] = $article_author;
|
$item['author'] = $article_author;
|
||||||
$item['enclosures'] = $article_thumbnail;
|
$item['enclosures'] = $article_thumbnail;
|
||||||
$item['timestamp'] = $article_timestamp;
|
$item['timestamp'] = $article_timestamp;
|
||||||
$item['content'] = trim($contents);
|
$item['content'] = trim($contents ?? '');
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
$limit++;
|
$limit++;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user