Skip to content

Instantly share code, notes, and snippets.

@ybenjo
Created November 30, 2012 13:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ybenjo/4175859 to your computer and use it in GitHub Desktop.
Save ybenjo/4175859 to your computer and use it in GitHub Desktop.
生駒日記取得
# usage: ruby ikoma.rb | pbcopy
require 'nokogiri'
require 'open-uri'
doc = Nokogiri::HTML(open("http://d.hatena.ne.jp/mamoruk/archive?word=&of=#{rand(1550)}", :proxy => nil).read)
entries = (doc/'li.archive.archive-section'/'a'); elem = entries[rand(entries.size)]
puts "#{elem.inner_text} #{elem.attribute('href').value}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment