Skip to content

Commit

Permalink
[Drive2ruBridge] Fixed incorrect titles and URLs in logbooks (#2215)
Browse files Browse the repository at this point in the history
  • Loading branch information
dotter-ak committed Jul 20, 2021
1 parent 3050f0a commit 126cf1a
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion bridges/Drive2ruBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,28 @@ private function getUserContent($url) {
}
}

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;
Expand Down Expand Up @@ -160,7 +182,7 @@ public function collectData() {
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')))
Expand Down

0 comments on commit 126cf1a

Please sign in to comment.