mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-04-09 16:38:50 +00:00
[NFLRUS] fix: broken css selectors (#2640)
This bridge needs more work.
This commit is contained in:
parent
b6e8e3ea6e
commit
563c099d80
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class NFLRUSBridge extends BridgeAbstract {
|
class NFLRUSBridge extends BridgeAbstract {
|
||||||
|
|
||||||
const NAME = 'NFLRUS';
|
const NAME = 'NFLRUS';
|
||||||
@ -6,52 +7,19 @@ class NFLRUSBridge extends BridgeAbstract {
|
|||||||
const DESCRIPTION = 'Returns the recent articles published on nflrus.ru';
|
const DESCRIPTION = 'Returns the recent articles published on nflrus.ru';
|
||||||
const MAINTAINER = 'Maxim Shpak';
|
const MAINTAINER = 'Maxim Shpak';
|
||||||
|
|
||||||
private function getEnglishMonth($month) {
|
|
||||||
$months = array(
|
|
||||||
'Января' => 'January',
|
|
||||||
'Февраля' => 'February',
|
|
||||||
'Марта' => 'March',
|
|
||||||
'Апреля' => 'April',
|
|
||||||
'Мая' => 'May',
|
|
||||||
'Июня' => 'June',
|
|
||||||
'Июля' => 'July',
|
|
||||||
'Августа' => 'August',
|
|
||||||
'Сентября' => 'September',
|
|
||||||
'Октября' => 'October',
|
|
||||||
'Ноября' => 'November',
|
|
||||||
'Декабря' => 'December',
|
|
||||||
);
|
|
||||||
|
|
||||||
if (isset($months[$month])) {
|
|
||||||
return $months[$month];
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function extractArticleTimestamp($article) {
|
|
||||||
$time = $article->find('time', 0);
|
|
||||||
if($time) {
|
|
||||||
$timestring = trim($time->plaintext);
|
|
||||||
$parts = explode(' ', $timestring);
|
|
||||||
$month = $this->getEnglishMonth($parts[1]);
|
|
||||||
if ($month) {
|
|
||||||
$timestring = $parts[0] . ' ' . $month . ' ' . $parts[2];
|
|
||||||
return strtotime($timestring);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function collectData() {
|
public function collectData() {
|
||||||
$html = getSimpleHTMLDOM(self::URI);
|
$html = getSimpleHTMLDOM(self::URI);
|
||||||
$html = defaultLinkTo($html, self::URI);
|
$html = defaultLinkTo($html, self::URI);
|
||||||
|
|
||||||
foreach($html->find('article') as $article) {
|
$articles = $html->find('.big-post_content-col');
|
||||||
|
|
||||||
|
foreach($articles as $article) {
|
||||||
$item = array();
|
$item = array();
|
||||||
$item['uri'] = $article->find('.b-article__title a', 0)->href;
|
|
||||||
$item['title'] = $article->find('.b-article__title a', 0)->plaintext;
|
$url = $article->find('.big-post_title.card-title a', 0);
|
||||||
$item['author'] = $article->find('.link-author', 0)->plaintext;
|
|
||||||
$item['timestamp'] = $this->extractArticleTimestamp($article);
|
$item['uri'] = $url->href;
|
||||||
|
$item['title'] = $url->plaintext;
|
||||||
$item['content'] = $article->find('div', 0)->innertext;
|
$item['content'] = $article->find('div', 0)->innertext;
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user