Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keisei1092/9acb1a18df2d1f3c5fdb4b401b00a81a to your computer and use it in GitHub Desktop.
Save keisei1092/9acb1a18df2d1f3c5fdb4b401b00a81a to your computer and use it in GitHub Desktop.

In your shell,

$ mkdir doujin-circle-scrape
$ cd doujin-circle-scrape
$ bundle init
$ emacs Gemfile

In Gemfile, add following to end

gem 'twitter'
gem 'pry'

In your shell,

$ bundle install --path='vendor/bundle'
$ emacs main.rb

In main.rb,

require 'twitter'
require 'pry'

client = Twitter::REST::Client.new do |config|
  config.consumer_key        = "xxxxxxxxxxxxxxxxxxxxx"
  config.consumer_secret     = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  config.access_token        = "12345678-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  config.access_token_secret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
end

pry

In your shell,

$ ruby main.rb

In pry console,

users = []
(users << client.user_search('ティア', { page: 1 })).flatten!)
(users << client.user_search('ティア', { page: 2 })).flatten!)
(users << client.user_search('ティア', { page: 3 })).flatten!)
...
out = ''
users.each { |u| out << "#{u.name},@#{u.screen_name},#{u.followers_count}\n" }
File.open('/Users/your_name/Desktop/hoge.txt', 'w') { |f| f.write(out) }

After creating hoge.txt, for example put it Google Spreadsheets. That's it! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment