twitter をいじるメモ
書き捨てコードをメモっておきます
# -*- coding: utf-8 -*- # sample.rb require 'open-uri' require 'rubygems' require 'nokogiri' user = "kenkiti" url = "https://api.twitter.com/1/users/lookup.xml?screen_name=#{user}" doc = Nokogiri::XML(open(url)) doc.xpath("//user/status").each do |node| p node.xpath("source") end
実行結果↓
/Users/kenkiti/temp% ruby sample.rb "<a href=\"http://itunes.apple.com/us/app/twitter/id409789998?mt=12\" rel=\"nofollow\">Twitter for Mac</a>"