Skip to content

Instantly share code, notes, and snippets.

@koshian
Created July 20, 2015 08:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koshian/f61a39b1da320c99fa42 to your computer and use it in GitHub Desktop.
Save koshian/f61a39b1da320c99fa42 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
require 'open-uri'
uri = 'http://b.hatena.ne.jp/hotentry'
query = '#main h3 a'
doc = Nokogiri::HTML.parse(open(uri).read)
doc.search(query).each do |e|
puts e.inner_html
puts e[:href]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment