Skip to content

Instantly share code, notes, and snippets.

@naoto
Created April 19, 2010 04:04
Show Gist options
  • Save naoto/370737 to your computer and use it in GitHub Desktop.
Save naoto/370737 to your computer and use it in GitHub Desktop.
TwitterのListからmemberのscreennameをブッコ抜き
#!/usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
require 'uri'
require 'open-uri'
require 'timeout'
def getScreenName(address)
p address
timeout(nil){
url = URI.escape(address)
html = Nokogiri::HTML(open(url))
screen = []
html.search(".screenname").each { |f|
screen << f.inner_text
}
nextpage = html.at("#pagination a")
screen += getScreenName("http://twitter.com/#{nextpage['href']}") if !nextpage.nil? && nextpage['href'] =~ /(=[^-][\d]+)$/
screen
}
end
screen = getScreenName(ARGV[0])
f = open("screen", 'w+')
f.puts screen.to_yaml
f.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment