Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
require 'rexml/document'
require 'pp'
require 'open-uri'
require 'date'
MARKTAG = "もきゅ";
user = "kimitoboku035"
doc = REXML::Document.new(open("http://b.hatena.ne.jp/#{user}/atomfeed?date=#{Time.now.strftime("%Y%m%d")}"));
pp "http://b.hatena.ne.jp/#{user}/atomfeed?date=#{Time.now.strftime("%Y%m%d")}"
elem = REXML::XPath.match(doc,'feed/entry');
elem.each_with_index do |e,i|
flag = false;
puts("#{i}----------")
e.each_element('dc:subject') do |tag|
if(tag.text == MARKTAG) then
flag = true;
end
puts tag.text;
end
if(flag==true) then
e.each_element('title') do |title|
puts title.text;
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment