Skip to content

Commit

Permalink
[VkBridge] Converting hashtags to categories (#755)
Browse files Browse the repository at this point in the history
* [VkBridge] Converting hashtags to categories
  • Loading branch information
em92 authored and teromene committed Jul 22, 2018
1 parent bae7a58 commit 43bb17f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions bridges/VkBridge.php
Expand Up @@ -228,6 +228,19 @@ public function collectData()
$item = array();
$item['content'] = strip_tags(backgroundToImg($post->find('div.wall_text', 0)->innertext), '<br><img>');
$item['content'] .= $content_suffix;
$item['categories'] = array();

// get post hashtags
foreach($post->find('a') as $a) {
$href = $a->getAttribute('href');
$prefix = '/feed?section=search&q=%23';
$innertext = $a->innertext;
if ($href && substr($href, 0, strlen($prefix)) === $prefix) {
$item['categories'][] = urldecode(substr($href, strlen($prefix)));
} else if (substr($innertext, 0, 1) == '#') {
$item['categories'][] = $innertext;
}
}

// get post link
$post_link = $post->find('a.post_link', 0)->getAttribute('href');
Expand Down

0 comments on commit 43bb17f

Please sign in to comment.