Skip to content

Instantly share code, notes, and snippets.

@sorah
Created August 8, 2009 08:23
Show Gist options
  • Save sorah/164357 to your computer and use it in GitHub Desktop.
Save sorah/164357 to your computer and use it in GitHub Desktop.
require 'rubygems';require 'mechanize'
(puts "usage: g91twitter2tab.rb (csv|tween)";exit) if !ARGV[0]
agent = WWW::Mechanize.new;agent.get('http://generation1991.g.hatena.ne.jp/keyword/%E3%83%A1%E3%83%B3%E3%83%90%E3%83%BC%E4%B8%80%E8%A6%A7')
twits = [];agent.page.search(".section/table/tr/td[3]/a").each{|x|twits << x.inner_text}
if ARGV[0] =~ /csv/
twits.each{|x| print x+","}
else
twits.each do |x|
text = <<EOF
<FiltersClass>
<NameFilter>#{x.sub(/^@/,"")}</NameFilter>
<BodyFilterArray />
<SearchBoth>true</SearchBoth>
<MoveFrom>false</MoveFrom>
<SetMark>false</SetMark>
<SearchUrl>false</SearchUrl>
<UseRegex>false</UseRegex>
</FiltersClass>
EOF
puts text
end
end
puts ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment