Skip to content

Instantly share code, notes, and snippets.

@t0d0r
Created December 21, 2011 11:37
Show Gist options
  • Save t0d0r/1505730 to your computer and use it in GitHub Desktop.
Save t0d0r/1505730 to your computer and use it in GitHub Desktop.
code sample for using nokogiri
require 'open-uri'
require 'nokogiri'
require 'erb'
include ERB::Util
q=url_encode("site:shipspotting.com 7224693 IMO")
doc = Nokogiri::HTML(open("http://www.google.com/search?q=#{q}"))
#link = doc.css("h3.r > a").first
#`open #{link['href']}`
doc.css("h3.r > a").each do |link|
puts link.content
puts "\t" + link['href']
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment