From 126cf1a7fa6ab68c32fdcc29328c02cd5b576a79 Mon Sep 17 00:00:00 2001 From: dotter-ak Date: Tue, 20 Jul 2021 11:03:17 +0300 Subject: [PATCH] [Drive2ruBridge] Fixed incorrect titles and URLs in logbooks (#2215) --- bridges/Drive2ruBridge.php | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/bridges/Drive2ruBridge.php b/bridges/Drive2ruBridge.php index d920d465..60df97d7 100644 --- a/bridges/Drive2ruBridge.php +++ b/bridges/Drive2ruBridge.php @@ -98,6 +98,28 @@ class Drive2ruBridge extends BridgeAbstract { } } + private function getLogbooksContent($url) { + $html = getSimpleHTMLDOM($url); + $this->title = $html->find('title', 0)->innertext; + $articles = $html->find('div.js-entity'); + foreach ($articles as $article) { + $item = array(); + $item['title'] = $article->find('a.c-link--text', 1)->plaintext; + $item['uri'] = urljoin(self::URI, $article->find('a.c-link--text', 1)->href); + if($this->getInput('full_articles')) { + $item['content'] = $this->addCommentsLink( + $this->adjustContent(getSimpleHTMLDomCached($item['uri'])->find('div.c-post__body', 0))->innertext, + $item['uri'] + ); + } else { + $item['content'] = $this->addReadMoreLink($article->find('div.c-post-preview__lead', 0), $item['uri']); + } + $item['author'] = $article->find('a.c-username--wrap', 0)->plaintext; + if (!is_null($article->find('img', 1))) $item['enclosures'][] = $article->find('img', 1)->src; + $this->items[] = $item; + } + } + private function getNews() { $html = getSimpleHTMLDOM('https://www.drive2.ru/editorial/'); $this->title = $html->find('title', 0)->innertext; @@ -160,7 +182,7 @@ class Drive2ruBridge extends BridgeAbstract { case 'Бортжурналы (По модели или марке)': if (!preg_match('/^https:\/\/www.drive2.ru\/experience/', $this->getInput('url'))) returnServerError('Invalid url'); - $this->getUserContent($this->getInput('url')); + $this->getLogbooksContent($this->getInput('url')); break; case 'Личные блоги': if (!preg_match('/^[a-zA-Z0-9-]{3,16}$/', $this->getInput('username')))