Created
December 21, 2011 11:37
-
-
Save t0d0r/1505730 to your computer and use it in GitHub Desktop.
code sample for using nokogiri
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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