LoginSignup
33

More than 5 years have passed since last update.

ソーシャル上でシェアされている数が一発でわかるRubyGem「social_counter」が便利

Last updated at Posted at 2014-04-04

いつ使えるの?

あるWebサイトがTwitter、Facebook、はてなブックマークなどのソーシャルメディア上で、 どれくらいシェアされているか を知りたい時に使えます。

公式リポジトリ

social_counterをインストール

Gemfile
  gem 'social_counter'

$ bndle install --path vendor/bundle

で gem をインストールする。

スクリプト(調べたいURLを引数でもらう)

social_count.rb
require 'social_counter'

# 引数でもらう
url = ARGV[0]
@sc = SocialCounter.new(url)
p "タイトル:#{@sc.title}"
p "Twitter:#{@sc.twitter_count}"
p "Facebook:#{@sc.facebook_count}"
p "Hatena:#{@sc.hatena_count}"
p "Pocket:#{@sc.pocket_count}"
p "Google:#{@sc.google_count}"

$ bundle exec ruby social_count.rb http://mossmoss.com/

調べたいURLを引数で渡して実行する。

実行結果

"タイトル:もすもすもすもす"
"Twitter:2300"
"Facebook:8338"
"Hatena:422"
"Pocket:501"
"Google:62"

調べられるSNS一覧

Twitter
Facebook
Hatena Bookmark
Google Plus
Pocket
Linkedin
Delicious
Pinterest
Reddit

便利ですね。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
33