顔文字の取得
ここから取得 http://kaomojiya.com/
#!/usr/bin/env ruby require 'rubygems' require 'nokogiri' require 'open-uri' $KCODE = 'u' if ARGV.size < 1 STDERR.puts 'require : output filename' STDERR.puts 'e.g. ruby get-kaomoji.rb out.txt' exit 1 end begin out = open(ARGV.first, 'w+') rescue STDERR.puts "can't open output file" exit 1 end doc = Nokogiri::HTML open('http://kaomojiya.com/') p urls = doc.xpath('//a').map{|a| a['href'] }.delete_if{|url| !(url =~ /^kao\/\?/) }.map{|url| 'http://kaomojiya.com/'+url } for url in urls do sleep 5 begin doc = Nokogiri::HTML open(url) doc.xpath('//div[@id="main"]//td').each{|td| puts td.text out.puts td.text } rescue Timeout::Error => e STDERR.puts e rescue => e STDERR.puts e end end out.close
取得したデータを使う
http://github.com/shokai/glitchtweet/blob/master/plugins/face.rb